[ovs-dev] [PATCH v3 1/3] ofproto-dpif-xlate: Create XC_LEARN entry after learning.
Daniele Di Proietto
diproiettod at vmware.com
Fri Mar 10 23:44:38 UTC 2017
This will be useful in a separate commit, because learning can fail.
Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
Acked-by: Ben Pfaff <blp at ovn.org>
---
ofproto/ofproto-dpif-xlate.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 8ce6a5939..8c4b714b2 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4579,11 +4579,7 @@ xlate_learn_action(struct xlate_ctx *ctx, const struct ofpact_learn *learn)
enum ofperr error;
if (ctx->xin->xcache) {
- struct xc_entry *entry;
-
- entry = xlate_cache_add_entry(ctx->xin->xcache, XC_LEARN);
- entry->learn.ofm = xmalloc(sizeof *entry->learn.ofm);
- ofm = entry->learn.ofm;
+ ofm = xmalloc(sizeof *ofm);
} else {
ofm = &ofm__;
}
@@ -4617,8 +4613,22 @@ xlate_learn_action(struct xlate_ctx *ctx, const struct ofpact_learn *learn)
&fm, ofm);
ofpbuf_uninit(&ofpacts);
- if (!error && ctx->xin->allow_side_effects) {
- error = ofproto_flow_mod_learn(ofm, ctx->xin->xcache != NULL);
+ if (!error) {
+ if (ctx->xin->allow_side_effects) {
+ error = ofproto_flow_mod_learn(ofm, ctx->xin->xcache != NULL);
+ }
+
+ if (ctx->xin->xcache) {
+ struct xc_entry *entry;
+
+ entry = xlate_cache_add_entry(ctx->xin->xcache, XC_LEARN);
+ entry->learn.ofm = ofm;
+ ofm = NULL;
+ }
+ }
+
+ if (ctx->xin->xcache) {
+ free(ofm);
}
if (error) {
--
2.11.0
More information about the dev
mailing list