mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
ofp-actions: Add limit to learn action.
This commit adds a new feature to the learn actions: the possibility to limit the number of learned flows. To be compatible with users of the old learn action, a new structure is introduced as well as a new OpenFlow raw action number. There's a small corner case when we have to delete the ukey. This happens when: * The learned rule has expired (or has been deleted). * The ukey that learned the rule is still in the datapath. * No packets hit the datapath flow recently. In this case we cannot relearn the rule (because there are no new packets), and the actions might depend on the learn execution, so the only option is to delete the ukey. I don't think this has big performance implications since it's done only for ukey with no traffic. We could also slowpath it, but that will cause an action upcall and the correct datapath actions will be installed later by a revalidator. If we delete the ukey, the next upcall will be a miss upcall and that will immediatedly install the correct datapath flow. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
committed by
Ben Pfaff
parent
2ce5f3114b
commit
4c71600d22
24
lib/learn.c
24
lib/learn.c
@@ -412,6 +412,22 @@ learn_parse__(char *orig, char *arg, struct ofpbuf *ofpacts)
|
||||
learn->flags |= NX_LEARN_F_SEND_FLOW_REM;
|
||||
} else if (!strcmp(name, "delete_learned")) {
|
||||
learn->flags |= NX_LEARN_F_DELETE_LEARNED;
|
||||
} else if (!strcmp(name, "limit")) {
|
||||
learn->limit = atoi(value);
|
||||
} else if (!strcmp(name, "result_dst")) {
|
||||
char *error;
|
||||
learn->flags |= NX_LEARN_F_WRITE_RESULT;
|
||||
error = mf_parse_subfield(&learn->result_dst, value);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
if (!learn->result_dst.field->writable) {
|
||||
return xasprintf("%s is read-only", value);
|
||||
}
|
||||
if (learn->result_dst.n_bits != 1) {
|
||||
return xasprintf("result_dst in 'learn' action must be a "
|
||||
"single bit");
|
||||
}
|
||||
} else {
|
||||
struct ofpact_learn_spec *spec;
|
||||
char *error;
|
||||
@@ -493,6 +509,14 @@ learn_format(const struct ofpact_learn *learn, struct ds *s)
|
||||
ds_put_format(s, ",%scookie=%s%#"PRIx64,
|
||||
colors.param, colors.end, ntohll(learn->cookie));
|
||||
}
|
||||
if (learn->limit != 0) {
|
||||
ds_put_format(s, ",%slimit=%s%"PRIu32,
|
||||
colors.param, colors.end, learn->limit);
|
||||
}
|
||||
if (learn->flags & NX_LEARN_F_WRITE_RESULT) {
|
||||
ds_put_format(s, ",%sresult_dst=%s", colors.param, colors.end);
|
||||
mf_format_subfield(&learn->result_dst, s);
|
||||
}
|
||||
|
||||
OFPACT_LEARN_SPEC_FOR_EACH (spec, learn) {
|
||||
unsigned int n_bytes = DIV_ROUND_UP(spec->n_bits, 8);
|
||||
|
Reference in New Issue
Block a user