diff options
author | Jarno Rajahalme <jarno@ovn.org> | 2016-09-14 16:51:27 -0700 |
---|---|---|
committer | Jarno Rajahalme <jarno@ovn.org> | 2016-09-14 16:51:27 -0700 |
commit | 2c7ee5248496896b3794df1d8635b70370097847 (patch) | |
tree | fadc512acfe3ac4984c1e4bdc6d15780052072b3 /ofproto/ofproto-dpif-xlate-cache.c | |
parent | a027899ee3e5a65c9253a24be8f8abdd9c47a023 (diff) | |
download | openvswitch-2c7ee5248496896b3794df1d8635b70370097847.tar.gz |
ofproto: Use ofproto_flow_mod for learn execution from xlate cache.
Use ofproto_flow_mod with a reference to an existing or new rule
instead of ofputil_flow_mod for learn action execution from xlate
cache
Typically we would find that when a learn xlate cache entry is
created, a preceding upcall has already created the learned flow. In
this case the xlate cache entry takes a reference to that flow and
keeps refreshing it without needing to perform any flow table lookups.
Otherwise the creation of the xlate cache entry creates the new rule,
which is then subsequently added to the classifier. In both cases
this is both faster and shrinks the memory cost of each learn cache
entry from ~3.5kb to about 0.3kb.
If the learned rule does not yet exist, it is created and attached to
the ofproto_flow_mod, from which it is then added. If the referred
rule happens to expire, or is modified in any way and is thus removed
from the classifier tables, we create a new rule using the old rule as
a template, so that we can avoid storing the ofputil_flow_mod in all
cases.
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/ofproto-dpif-xlate-cache.c')
-rw-r--r-- | ofproto/ofproto-dpif-xlate-cache.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ofproto/ofproto-dpif-xlate-cache.c b/ofproto/ofproto-dpif-xlate-cache.c index eef76bbb1..0dd40fdec 100644 --- a/ofproto/ofproto-dpif-xlate-cache.c +++ b/ofproto/ofproto-dpif-xlate-cache.c @@ -115,9 +115,15 @@ xlate_push_stats_entry(struct xc_entry *entry, entry->mirror.mirrors, stats->n_packets, stats->n_bytes); break; - case XC_LEARN: - ofproto_dpif_flow_mod(entry->learn.ofproto, entry->learn.fm); + case XC_LEARN: { + enum ofperr error; + error = ofproto_flow_mod_learn(entry->learn.ofm, true); + if (error) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "xcache LEARN action execution failed."); + } break; + } case XC_NORMAL: xlate_mac_learning_update(entry->normal.ofproto, entry->normal.in_port, @@ -205,8 +211,8 @@ xlate_cache_clear_entry(struct xc_entry *entry) mbridge_unref(entry->mirror.mbridge); break; case XC_LEARN: - free(entry->learn.fm); - ofpbuf_delete(entry->learn.ofpacts); + ofproto_flow_mod_uninit(entry->learn.ofm); + free(entry->learn.ofm); break; case XC_NORMAL: break; |