~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to tests/test-bundle.c

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2011, 2012 Nicira, Inc.
 
1
/* Copyright (c) 2011, 2012, 2013 Nicira, Inc.
2
2
 *
3
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
4
 * you may not use this file except in compliance with the License.
31
31
#define MAX_SLAVES 8 /* Maximum supported by this test framework. */
32
32
 
33
33
struct slave {
34
 
    uint16_t slave_id;
 
34
    ofp_port_t slave_id;
35
35
 
36
36
    bool enabled;
37
37
    size_t flow_count;
43
43
};
44
44
 
45
45
static struct slave *
46
 
slave_lookup(struct slave_group *sg, uint16_t slave_id)
 
46
slave_lookup(struct slave_group *sg, ofp_port_t slave_id)
47
47
{
48
48
    size_t i;
49
49
 
57
57
}
58
58
 
59
59
static bool
60
 
slave_enabled_cb(uint16_t slave_id, void *aux)
 
60
slave_enabled_cb(ofp_port_t slave_id, void *aux)
61
61
{
62
62
    struct slave *slave;
63
63
 
71
71
    struct ofpact_bundle *bundle;
72
72
    struct ofpbuf ofpacts;
73
73
    struct ofpact *action;
 
74
    char *error;
74
75
 
75
76
    ofpbuf_init(&ofpacts, 0);
76
 
    bundle_parse_load(actions, &ofpacts);
 
77
    error = bundle_parse_load(actions, &ofpacts);
 
78
    if (error) {
 
79
        ovs_fatal(0, "%s", error);
 
80
    }
 
81
 
77
82
    action = ofpacts.data;
78
83
    bundle = ofpact_get_BUNDLE(xmemdup(action, action->len));
79
84
    ofpbuf_uninit(&ofpacts);
122
127
    /* Generate 'slaves' array. */
123
128
    sg.n_slaves = 0;
124
129
    for (i = 0; i < bundle->n_slaves; i++) {
125
 
        uint16_t slave_id = bundle->slaves[i];
 
130
        ofp_port_t slave_id = bundle->slaves[i];
126
131
 
127
132
        if (slave_lookup(&sg, slave_id)) {
128
133
            ovs_fatal(0, "Redundant slaves are not supported. ");
137
142
    for (i = 0; i < N_FLOWS; i++) {
138
143
        random_bytes(&flows[i], sizeof flows[i]);
139
144
        memset(flows[i].zeros, 0, sizeof flows[i].zeros);
140
 
        flows[i].regs[0] = OFPP_NONE;
 
145
        flows[i].mpls_depth = 0;
 
146
        flows[i].regs[0] = ofp_to_u16(OFPP_NONE);
141
147
    }
142
148
 
143
149
    /* Cycles through each possible liveness permutation for the given
185
191
        changed = 0;
186
192
        for (j = 0; j < N_FLOWS; j++) {
187
193
            struct flow *flow = &flows[j];
188
 
            uint16_t old_slave_id, ofp_port;
 
194
            ofp_port_t old_slave_id, ofp_port;
 
195
            struct flow_wildcards wc;
189
196
 
190
 
            old_slave_id = flow->regs[0];
191
 
            ofp_port = bundle_execute(bundle, flow, slave_enabled_cb, &sg);
192
 
            flow->regs[0] = ofp_port;
 
197
            old_slave_id = u16_to_ofp(flow->regs[0]);
 
198
            ofp_port = bundle_execute(bundle, flow, &wc, slave_enabled_cb,
 
199
                                      &sg);
 
200
            flow->regs[0] = ofp_to_u16(ofp_port);
193
201
 
194
202
            if (ofp_port != OFPP_NONE) {
195
203
                slave_lookup(&sg, ofp_port)->flow_count++;