VLOG_DEFINE_THIS_MODULE(bundle);
-/* Executes 'nab' on 'flow'. Uses 'slave_enabled' to determine if the slave
- * designated by 'ofp_port' is up. Returns the chosen slave, or OFPP_NONE if
- * none of the slaves are acceptable. */
-uint16_t
-bundle_execute(const struct nx_action_bundle *nab, const struct flow *flow,
- bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
+static uint16_t
+execute_ab(const struct nx_action_bundle *nab,
+ bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
+{
+ size_t i;
+
+ for (i = 0; i < ntohs(nab->n_slaves); i++) {
+ uint16_t slave = bundle_get_slave(nab, i);
+
+ if (slave_enabled(slave, aux)) {
+ return slave;
+ }
+ }
+
+ return OFPP_NONE;
+}
+
+static uint16_t
+execute_hrw(const struct nx_action_bundle *nab, const struct flow *flow,
+ bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
{
uint32_t flow_hash, best_hash;
int best, i;
- assert(nab->algorithm == htons(NX_BD_ALG_HRW));
-
flow_hash = flow_hash_fields(flow, ntohs(nab->fields), ntohs(nab->basis));
best = -1;
+ best_hash = 0;
for (i = 0; i < ntohs(nab->n_slaves); i++) {
if (slave_enabled(bundle_get_slave(nab, i), aux)) {
return best >= 0 ? bundle_get_slave(nab, best) : OFPP_NONE;
}
+/* Executes 'nab' on 'flow'. Uses 'slave_enabled' to determine if the slave
+ * designated by 'ofp_port' is up. Returns the chosen slave, or OFPP_NONE if
+ * none of the slaves are acceptable. */
+uint16_t
+bundle_execute(const struct nx_action_bundle *nab, const struct flow *flow,
+ bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
+{
+ switch (ntohs(nab->algorithm)) {
+ case NX_BD_ALG_HRW: return execute_hrw(nab, flow, slave_enabled, aux);
+ case NX_BD_ALG_ACTIVE_BACKUP: return execute_ab(nab, slave_enabled, aux);
+ default: NOT_REACHED();
+ }
+}
+
/* Checks that 'nab' specifies a bundle action which is supported by this
* bundle module. Uses the 'max_ports' parameter to validate each port using
* ofputil_check_output_port(). Returns 0 if 'nab' is supported, otherwise an
bundle_check(const struct nx_action_bundle *nab, int max_ports)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
- uint16_t n_slaves, fields, algorithm, slave_type, subtype;
+ uint16_t n_slaves, fields, algorithm, subtype;
+ uint32_t slave_type;
size_t slaves_size, i;
int error;
n_slaves = ntohs(nab->n_slaves);
fields = ntohs(nab->fields);
algorithm = ntohs(nab->algorithm);
- slave_type = ntohs(nab->slave_type);
+ slave_type = ntohl(nab->slave_type);
slaves_size = ntohs(nab->len) - sizeof *nab;
error = ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_ARGUMENT);
VLOG_WARN_RL(&rl, "unsupported fields %"PRIu16, fields);
} else if (n_slaves > BUNDLE_MAX_SLAVES) {
VLOG_WARN_RL(&rl, "too may slaves");
- } else if (algorithm != NX_BD_ALG_HRW) {
+ } else if (algorithm != NX_BD_ALG_HRW
+ && algorithm != NX_BD_ALG_ACTIVE_BACKUP) {
VLOG_WARN_RL(&rl, "unsupported algorithm %"PRIu16, algorithm);
} else if (slave_type != NXM_OF_IN_PORT) {
VLOG_WARN_RL(&rl, "unsupported slave type %"PRIu16, slave_type);
}
if (!strcasecmp(slave_type, "ofport")) {
- nab->slave_type = htons(NXM_OF_IN_PORT);
+ nab->slave_type = htonl(NXM_OF_IN_PORT);
} else {
ovs_fatal(0, "%s: unknown slave_type `%s'", s, slave_type);
}
algorithm = "<unknown>";
}
- switch (ntohs(nab->slave_type)) {
+ switch (ntohl(nab->slave_type)) {
case NXM_OF_IN_PORT:
slave_type = "ofport";
break;