summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-08-07 15:28:18 -0700
committerBen Pfaff <blp@nicira.com>2012-09-04 12:24:27 -0700
commit81a76618be9ea195a1e4a881ba9591728891d10b (patch)
tree4e87f0e245d09a8b0fb5bc2fe19bf3ae0cb6cbe7 /tests
parentdbda2960f64238e80570aafeae7af5a752f54f59 (diff)
downloadopenvswitch-81a76618be9ea195a1e4a881ba9591728891d10b.tar.gz
classifier: Break cls_rule 'flow' and 'wc' members into new "struct match".
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ofp-print.at8
-rw-r--r--tests/test-classifier.c92
-rw-r--r--tests/test-flows.c8
3 files changed, 56 insertions, 52 deletions
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 3c55d9108..9844592e1 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -455,8 +455,8 @@ AT_CHECK([ovs-ofctl '-vPATTERN:console:%c|%p|%m' ofp-print "\
OFPT_FLOW_MOD (xid=0x0): ADD priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2 idle:5 buf:0x10e out_port:0 actions=output:3
], [dnl
ofp_util|INFO|normalization changed ofp_match, details:
-ofp_util|INFO| pre: priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0
-ofp_util|INFO|post: priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2
+ofp_util|INFO| pre: arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0
+ofp_util|INFO|post: arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2
])
AT_CLEANUP
@@ -493,8 +493,8 @@ AT_CHECK([ovs-ofctl '-vPATTERN:console:%c|%p|%m' ofp-print "\
OFPT_FLOW_MOD (xid=0x0): ADD arp,in_port=1,dl_vlan=65535,dl_vlan_pcp=0,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0 idle:5 pri:65535 buf:0x10e out_port:0 actions=output:3
], [dnl
ofp_util|INFO|normalization changed ofp_match, details:
-ofp_util|INFO| pre: priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0
-ofp_util|INFO|post: priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2
+ofp_util|INFO| pre: arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0
+ofp_util|INFO|post: arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,arp_op=2
])
AT_CLEANUP
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 3ee6ddb63..f279bda1e 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -186,44 +186,44 @@ match(const struct cls_rule *wild, const struct flow *fixed)
bool eq;
if (f_idx == CLS_F_IDX_NW_SRC) {
- eq = !((fixed->nw_src ^ wild->flow.nw_src)
- & wild->wc.masks.nw_src);
+ eq = !((fixed->nw_src ^ wild->match.flow.nw_src)
+ & wild->match.wc.masks.nw_src);
} else if (f_idx == CLS_F_IDX_NW_DST) {
- eq = !((fixed->nw_dst ^ wild->flow.nw_dst)
- & wild->wc.masks.nw_dst);
+ eq = !((fixed->nw_dst ^ wild->match.flow.nw_dst)
+ & wild->match.wc.masks.nw_dst);
} else if (f_idx == CLS_F_IDX_TP_SRC) {
- eq = !((fixed->tp_src ^ wild->flow.tp_src)
- & wild->wc.masks.tp_src);
+ eq = !((fixed->tp_src ^ wild->match.flow.tp_src)
+ & wild->match.wc.masks.tp_src);
} else if (f_idx == CLS_F_IDX_TP_DST) {
- eq = !((fixed->tp_dst ^ wild->flow.tp_dst)
- & wild->wc.masks.tp_dst);
+ eq = !((fixed->tp_dst ^ wild->match.flow.tp_dst)
+ & wild->match.wc.masks.tp_dst);
} else if (f_idx == CLS_F_IDX_DL_SRC) {
- eq = eth_addr_equal_except(fixed->dl_src, wild->flow.dl_src,
- wild->wc.masks.dl_src);
+ eq = eth_addr_equal_except(fixed->dl_src, wild->match.flow.dl_src,
+ wild->match.wc.masks.dl_src);
} else if (f_idx == CLS_F_IDX_DL_DST) {
- eq = eth_addr_equal_except(fixed->dl_dst, wild->flow.dl_dst,
- wild->wc.masks.dl_dst);
+ eq = eth_addr_equal_except(fixed->dl_dst, wild->match.flow.dl_dst,
+ wild->match.wc.masks.dl_dst);
} else if (f_idx == CLS_F_IDX_VLAN_TCI) {
- eq = !((fixed->vlan_tci ^ wild->flow.vlan_tci)
- & wild->wc.masks.vlan_tci);
+ eq = !((fixed->vlan_tci ^ wild->match.flow.vlan_tci)
+ & wild->match.wc.masks.vlan_tci);
} else if (f_idx == CLS_F_IDX_TUN_ID) {
- eq = !((fixed->tun_id ^ wild->flow.tun_id)
- & wild->wc.masks.tun_id);
+ eq = !((fixed->tun_id ^ wild->match.flow.tun_id)
+ & wild->match.wc.masks.tun_id);
} else if (f_idx == CLS_F_IDX_METADATA) {
- eq = !((fixed->metadata ^ wild->flow.metadata)
- & wild->wc.masks.metadata);
+ eq = !((fixed->metadata ^ wild->match.flow.metadata)
+ & wild->match.wc.masks.metadata);
} else if (f_idx == CLS_F_IDX_NW_DSCP) {
- eq = !((fixed->nw_tos ^ wild->flow.nw_tos) &
- (wild->wc.masks.nw_tos & IP_DSCP_MASK));
+ eq = !((fixed->nw_tos ^ wild->match.flow.nw_tos) &
+ (wild->match.wc.masks.nw_tos & IP_DSCP_MASK));
} else if (f_idx == CLS_F_IDX_NW_PROTO) {
- eq = !((fixed->nw_proto ^ wild->flow.nw_proto)
- & wild->wc.masks.nw_proto);
+ eq = !((fixed->nw_proto ^ wild->match.flow.nw_proto)
+ & wild->match.wc.masks.nw_proto);
} else if (f_idx == CLS_F_IDX_DL_TYPE) {
- eq = !((fixed->dl_type ^ wild->flow.dl_type)
- & wild->wc.masks.dl_type);
+ eq = !((fixed->dl_type ^ wild->match.flow.dl_type)
+ & wild->match.wc.masks.dl_type);
} else if (f_idx == CLS_F_IDX_IN_PORT) {
- eq = !((fixed->in_port ^ wild->flow.in_port)
- & wild->wc.masks.in_port);
+ eq = !((fixed->in_port ^ wild->match.flow.in_port)
+ & wild->match.wc.masks.in_port);
} else {
NOT_REACHED();
}
@@ -256,8 +256,9 @@ tcls_delete_matches(struct tcls *cls, const struct cls_rule *target)
for (i = 0; i < cls->n_rules; ) {
struct test_rule *pos = cls->rules[i];
- if (!flow_wildcards_has_extra(&pos->cls_rule.wc, &target->wc)
- && match(target, &pos->cls_rule.flow)) {
+ if (!flow_wildcards_has_extra(&pos->cls_rule.match.wc,
+ &target->match.wc)
+ && match(target, &pos->cls_rule.match.flow)) {
tcls_remove(cls, pos);
} else {
i++;
@@ -476,45 +477,48 @@ make_rule(int wc_fields, unsigned int priority, int value_pat)
{
const struct cls_field *f;
struct test_rule *rule;
+ struct match match;
- rule = xzalloc(sizeof *rule);
- cls_rule_init_catchall(&rule->cls_rule, wc_fields ? priority : UINT_MAX);
+ match_init_catchall(&match);
for (f = &cls_fields[0]; f < &cls_fields[CLS_N_FIELDS]; f++) {
int f_idx = f - cls_fields;
int value_idx = (value_pat & (1u << f_idx)) != 0;
- memcpy((char *) &rule->cls_rule.flow + f->ofs,
+ memcpy((char *) &match.flow + f->ofs,
values[f_idx][value_idx], f->len);
if (f_idx == CLS_F_IDX_NW_SRC) {
- rule->cls_rule.wc.masks.nw_src = htonl(UINT32_MAX);
+ match.wc.masks.nw_src = htonl(UINT32_MAX);
} else if (f_idx == CLS_F_IDX_NW_DST) {
- rule->cls_rule.wc.masks.nw_dst = htonl(UINT32_MAX);
+ match.wc.masks.nw_dst = htonl(UINT32_MAX);
} else if (f_idx == CLS_F_IDX_TP_SRC) {
- rule->cls_rule.wc.masks.tp_src = htons(UINT16_MAX);
+ match.wc.masks.tp_src = htons(UINT16_MAX);
} else if (f_idx == CLS_F_IDX_TP_DST) {
- rule->cls_rule.wc.masks.tp_dst = htons(UINT16_MAX);
+ match.wc.masks.tp_dst = htons(UINT16_MAX);
} else if (f_idx == CLS_F_IDX_DL_SRC) {
- memset(rule->cls_rule.wc.masks.dl_src, 0xff, ETH_ADDR_LEN);
+ memset(match.wc.masks.dl_src, 0xff, ETH_ADDR_LEN);
} else if (f_idx == CLS_F_IDX_DL_DST) {
- memset(rule->cls_rule.wc.masks.dl_dst, 0xff, ETH_ADDR_LEN);
+ memset(match.wc.masks.dl_dst, 0xff, ETH_ADDR_LEN);
} else if (f_idx == CLS_F_IDX_VLAN_TCI) {
- rule->cls_rule.wc.masks.vlan_tci = htons(UINT16_MAX);
+ match.wc.masks.vlan_tci = htons(UINT16_MAX);
} else if (f_idx == CLS_F_IDX_TUN_ID) {
- rule->cls_rule.wc.masks.tun_id = htonll(UINT64_MAX);
+ match.wc.masks.tun_id = htonll(UINT64_MAX);
} else if (f_idx == CLS_F_IDX_METADATA) {
- rule->cls_rule.wc.masks.metadata = htonll(UINT64_MAX);
+ match.wc.masks.metadata = htonll(UINT64_MAX);
} else if (f_idx == CLS_F_IDX_NW_DSCP) {
- rule->cls_rule.wc.masks.nw_tos |= IP_DSCP_MASK;
+ match.wc.masks.nw_tos |= IP_DSCP_MASK;
} else if (f_idx == CLS_F_IDX_NW_PROTO) {
- rule->cls_rule.wc.masks.nw_proto = UINT8_MAX;
+ match.wc.masks.nw_proto = UINT8_MAX;
} else if (f_idx == CLS_F_IDX_DL_TYPE) {
- rule->cls_rule.wc.masks.dl_type = htons(UINT16_MAX);
+ match.wc.masks.dl_type = htons(UINT16_MAX);
} else if (f_idx == CLS_F_IDX_IN_PORT) {
- rule->cls_rule.wc.masks.in_port = UINT16_MAX;
+ match.wc.masks.in_port = UINT16_MAX;
} else {
NOT_REACHED();
}
}
+
+ rule = xzalloc(sizeof *rule);
+ cls_rule_init(&rule->cls_rule, &match, wc_fields ? priority : UINT_MAX);
return rule;
}
diff --git a/tests/test-flows.c b/tests/test-flows.c
index 33417e021..a4d7c09e0 100644
--- a/tests/test-flows.c
+++ b/tests/test-flows.c
@@ -56,7 +56,7 @@ main(int argc OVS_UNUSED, char *argv[])
while (fread(&expected_match, sizeof expected_match, 1, flows)) {
struct ofpbuf *packet;
struct ofp10_match extracted_match;
- struct cls_rule rule;
+ struct match match;
struct flow flow;
n++;
@@ -69,8 +69,8 @@ main(int argc OVS_UNUSED, char *argv[])
}
flow_extract(packet, 0, 0, 1, &flow);
- cls_rule_init_exact(&flow, 0, &rule);
- ofputil_cls_rule_to_ofp10_match(&rule, &extracted_match);
+ match_init_exact(&match, &flow);
+ ofputil_match_to_ofp10_match(&match, &extracted_match);
if (memcmp(&expected_match, &extracted_match, sizeof expected_match)) {
char *exp_s = ofp10_match_to_string(&expected_match, 2);
@@ -80,7 +80,7 @@ main(int argc OVS_UNUSED, char *argv[])
printf("Packet:\n");
ofp_print_packet(stdout, packet->data, packet->size);
ovs_hex_dump(stdout, packet->data, packet->size, 0, true);
- cls_rule_print(&rule);
+ match_print(&match);
printf("Expected flow:\n%s\n", exp_s);
printf("Actually extracted flow:\n%s\n", got_s);
ovs_hex_dump(stdout, &expected_match, sizeof expected_match, 0, false);