2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

ofp-flow: Reduce memory consumption for ofputil_flow_mod, using minimatch.

Until now, struct ofputil_flow_mod, which represents an OpenFlow flow table
modification request, has incorporated a struct match, which made the
overall ofputil_flow_mod about 2.5 kB.  This is OK for a small number of
flows, but absurdly inflates memory requirements when there are hundreds of
thousands of flows.  This commit fixes the problem by changing struct match
to struct minimatch inside ofputil_flow_mod, which reduces its size to
about 100 bytes plus the actual size of the flow match (usually a few dozen
bytes).

This affects memory usage of ovs-ofctl (when it adds a large number of
flows) more than ovs-vswitchd.

Reported-by: Michael Ben-Ami <mbenami@digitalocean.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Armando Migliaccio <armamig@gmail.com>
Tested-by: Armando Migliaccio <armamig@gmail.com>
Reviewed-by: Jan Scheurich <jan.scheurich@ericsson.com>
Tested-by: Jan Scheurich <jan.scheurich@ericsson.com>
Tested-by: Yifeng Sun <pkusunyifeng@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
This commit is contained in:
Ben Pfaff
2018-03-19 22:01:47 -07:00
parent 1dc1ec247e
commit 6a6b706065
13 changed files with 185 additions and 113 deletions

View File

@@ -91,14 +91,17 @@ learn_check(const struct ofpact_learn *learn, const struct match *src_match)
* 'ofpacts' and retains ownership of it. 'fm->ofpacts' will point into the
* 'ofpacts' buffer.
*
* The caller must eventually destroy fm->match.
*
* The caller has to actually execute 'fm'. */
void
learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
struct ofputil_flow_mod *fm, struct ofpbuf *ofpacts)
{
const struct ofpact_learn_spec *spec;
struct match match;
match_init_catchall(&fm->match);
match_init_catchall(&match);
fm->priority = learn->priority;
fm->cookie = htonll(0);
fm->cookie_mask = htonll(0);
@@ -140,10 +143,10 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
switch (spec->dst_type) {
case NX_LEARN_DST_MATCH:
mf_write_subfield(&spec->dst, &value, &fm->match);
match_add_ethernet_prereq(&fm->match, spec->dst.field);
mf_write_subfield(&spec->dst, &value, &match);
match_add_ethernet_prereq(&match, spec->dst.field);
mf_vl_mff_set_tlv_bitmap(
spec->dst.field, &fm->match.flow.tunnel.metadata.present.map);
spec->dst.field, &match.flow.tunnel.metadata.present.map);
break;
case NX_LEARN_DST_LOAD:
@@ -173,6 +176,7 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
}
}
minimatch_init(&fm->match, &match);
fm->ofpacts = ofpacts->data;
fm->ofpacts_len = ofpacts->size;
}