No functional change, it will be used by next commit.
Signed-off-by: Daniele Di Proietto
---
lib/ofp-actions.c | 77 +++
1 file changed, 43 insertions(+), 34 deletions(-)
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index ce80f57e8..78f8c4366 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -4313,43 +4313,14 @@ learn_min_len(uint16_t header)
return min_len;
}
-/* Converts 'nal' into a "struct ofpact_learn" and appends that struct to
- * 'ofpacts'. Returns 0 if successful, otherwise an OFPERR_*. */
static enum ofperr
-decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
- enum ofp_version ofp_version OVS_UNUSED,
- const struct vl_mff_map *vl_mff_map,
- struct ofpbuf *ofpacts)
+decode_LEARN_common(const void *p, const void *end,
+const struct vl_mff_map *vl_mff_map,
+struct ofpbuf *ofpacts)
{
-struct ofpact_learn *learn;
-const void *p, *end;
+struct ofpact_learn *learn = ofpacts->header;
-if (nal->pad) {
-return OFPERR_OFPBAC_BAD_ARGUMENT;
-}
-
-learn = ofpact_put_LEARN(ofpacts);
-
-learn->idle_timeout = ntohs(nal->idle_timeout);
-learn->hard_timeout = ntohs(nal->hard_timeout);
-learn->priority = ntohs(nal->priority);
-learn->cookie = nal->cookie;
-learn->table_id = nal->table_id;
-learn->fin_idle_timeout = ntohs(nal->fin_idle_timeout);
-learn->fin_hard_timeout = ntohs(nal->fin_hard_timeout);
-
-learn->flags = ntohs(nal->flags);
-if (learn->flags & ~(NX_LEARN_F_SEND_FLOW_REM |
- NX_LEARN_F_DELETE_LEARNED)) {
-return OFPERR_OFPBAC_BAD_ARGUMENT;
-}
-
-if (learn->table_id == 0xff) {
-return OFPERR_OFPBAC_BAD_ARGUMENT;
-}
-
-end = (char *) nal + ntohs(nal->len);
-for (p = nal + 1; p != end; ) {
+while (p != end) {
struct ofpact_learn_spec *spec;
uint16_t header = ntohs(get_be16(&p));
@@ -4422,6 +4393,44 @@ decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
return 0;
}
+/* Converts 'nal' into a "struct ofpact_learn" and appends that struct to
+ * 'ofpacts'. Returns 0 if successful, otherwise an OFPERR_*. */
+static enum ofperr
+decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
+ enum ofp_version ofp_version OVS_UNUSED,
+ const struct vl_mff_map *vl_mff_map,
+ struct ofpbuf *ofpacts)
+{
+struct ofpact_learn *learn;
+
+if (nal->pad) {
+return OFPERR_OFPBAC_BAD_ARGUMENT;
+}
+
+learn = ofpact_put_LEARN(ofpacts);
+
+learn->idle_timeout = ntohs(nal->idle_timeout);
+learn->hard_timeout = ntohs(nal->hard_timeout);
+learn->priority = ntohs(nal->priority);
+learn->cookie = nal->cookie;
+learn->table_id = nal->table_id;
+learn->fin_idle_timeout = ntohs(nal->fin_idle_timeout);
+learn->fin_hard_timeout = ntohs(nal->fin_hard_timeout);
+
+learn->flags = ntohs(nal->flags);
+if (learn->flags & ~(NX_LEARN_F_SEND_FLOW_REM |
+ NX_LEARN_F_DELETE_LEARNED)) {
+return OFPERR_OFPBAC_BAD_ARGUMENT;
+}
+
+if (learn->table_id == 0xff) {
+return OFPERR_OFPBAC_BAD_ARGUMENT;
+}
+
+return decode_LEARN_common(nal + 1, (char *) nal + ntohs(nal->len),
+ vl_mff_map, ofpacts);
+}
+
static void
put_be16(struct ofpbuf *b, ovs_be16 x)
{
--
2.11.0
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev