示例#1
0
/* Handles flow mod messages with MODIFY command. 
    If the flow doesn't exists don't do nothing*/
static ofl_err
flow_table_modify(struct flow_table *table, struct ofl_msg_flow_mod *mod, bool strict, bool *insts_kept) {
    struct flow_entry *entry;

    LIST_FOR_EACH (entry, struct flow_entry, match_node, &table->match_entries) {
        if (flow_entry_matches(entry, mod, strict, true/*check_cookie*/)) {
            flow_entry_replace_instructions(entry, mod->instructions_num, mod->instructions);
            *insts_kept = true;
        }
    }

    return 0;
}
/* Handles flow mod messages with MODIFY command. */
static ofl_err
flow_table_modify(struct flow_table *table, struct ofl_msg_flow_mod *mod, bool strict, bool *match_kept, bool *insts_kept) {
    struct flow_entry *entry;
    bool match_found;

    match_found = false;

    LIST_FOR_EACH (entry, struct flow_entry, match_node, &table->match_entries) {
        if (flow_entry_matches(entry, mod, strict, true/*check_cookie*/)) {
            flow_entry_replace_instructions(entry, mod->instructions_num, mod->instructions);
            *insts_kept = true;
            match_found = true;
        }
    }

    /* NOTE: if modify does not modify any entries, it acts like an add according to spec. */
    if (!match_found) {
        return flow_table_add(table, mod, false, match_kept, insts_kept);
    }

    return 0;
}