[ovs-dev] [PATCH] fix some ofpbuf usage problems in write-actions code

YAMAMOTO Takashi yamamoto at valinux.co.jp
Thu Oct 17 10:01:55 UTC 2013


for longer term, "nested" variants of some ofpact functions
which using ofpbuf->l3 might be desirable.

Signed-off-by: YAMAMOTO Takashi <yamamoto at valinux.co.jp>
---
 lib/ofp-actions.c | 5 ++++-
 lib/ofp-parse.c   | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 06f9f6b..a5b1090 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1403,8 +1403,10 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
         struct ofpact_nest *on;
         const union ofp_action *actions;
         size_t n_actions;
-        size_t start = ofpacts->size;
+        size_t start;
 
+        ofpact_pad(ofpacts);
+        start = ofpacts->size;
         on = ofpact_put(ofpacts, OFPACT_WRITE_ACTIONS,
                         offsetof(struct ofpact_nest, actions));
         get_actions_from_instruction(insts[OVSINST_OFPIT11_WRITE_ACTIONS],
@@ -1414,6 +1416,7 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
         if (error) {
             goto exit;
         }
+        on = ofpbuf_at_assert(ofpacts, start, sizeof *on);
         on->ofpact.len = ofpacts->size - start;
     }
     if (insts[OVSINST_OFPIT11_WRITE_METADATA]) {
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index f55eb3f..2350de3 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -951,8 +951,10 @@ parse_named_instruction(enum ovs_instruction_type type,
 
     case OVSINST_OFPIT11_WRITE_ACTIONS: {
         struct ofpact_nest *on;
-        size_t ofs = ofpacts->size;
+        size_t ofs;
 
+        ofpact_pad(ofpacts);
+        ofs = ofpacts->size;
         on = ofpact_put(ofpacts, OFPACT_WRITE_ACTIONS,
                         offsetof(struct ofpact_nest, actions));
         error_s = str_to_ofpacts__(arg, ofpacts, usable_protocols);
-- 
1.8.3.1




More information about the dev mailing list