diff mbox

[ovs-dev] ofproto-dpif-xlate: use xlate error enum for unsupported packet type

Message ID AM2PR07MB1042FB77EC2C7EE64CF71AC88A870@AM2PR07MB1042.eurprd07.prod.outlook.com
State Accepted
Headers show

Commit Message

Zoltan Balogh Aug. 21, 2017, 8:34 a.m. UTC
Instead of using the value 1 a new enum should be used for indicating
translation error which occurs because of unsupported packet type.

Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Co-authored-by: Jan Scheurich <jan.scheurich@ericsson.com>
Fixes: f839892a206a ("OF support and translation of generic encap and
decap")
CC: Jan Scheurich <jan.scheurich@ericsson.com>
---
 ofproto/ofproto-dpif-xlate.c | 12 +++++++-----
 ofproto/ofproto-dpif-xlate.h |  1 +
 2 files changed, 8 insertions(+), 5 deletions(-)

Comments

Ben Pfaff Oct. 31, 2017, 8:09 p.m. UTC | #1
On Mon, Aug 21, 2017 at 08:34:41AM +0000, Zoltán Balogh wrote:
> Instead of using the value 1 a new enum should be used for indicating
> translation error which occurs because of unsupported packet type.
> 
> Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
> Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
> Co-authored-by: Jan Scheurich <jan.scheurich@ericsson.com>
> Fixes: f839892a206a ("OF support and translation of generic encap and
> decap")
> CC: Jan Scheurich <jan.scheurich@ericsson.com>

Thanks, applied to master and branch-2.8.
diff mbox

Patch

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 973e76054..d56a5de3a 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -424,6 +424,8 @@  const char *xlate_strerror(enum xlate_error error)
         return "Too many MPLS labels";
     case XLATE_INVALID_TUNNEL_METADATA:
         return "Invalid tunnel metadata";
+    case XLATE_UNSUPPORTED_PACKET_TYPE:
+        return "Unsupported packet type";
     }
     return "Unknown error";
 }
@@ -5798,7 +5800,7 @@  rewrite_flow_encap_ethernet(struct xlate_ctx *ctx,
         xlate_report_debug(ctx, OFT_ACTION,
                            "Dropping packet as encap(ethernet) is not "
                            "supported for packet type ethernet.");
-        ctx->error = 1;
+        ctx->error = XLATE_UNSUPPORTED_PACKET_TYPE;
     }
 }
 
@@ -5879,7 +5881,7 @@  rewrite_flow_encap_nsh(struct xlate_ctx *ctx,
                                "Dropping packet as encap(nsh) is not "
                                "supported for packet type (%d,0x%x)",
                                pt_ns(packet_type), pt_ns_type(packet_type));
-            ctx->error = 1;
+            ctx->error = XLATE_UNSUPPORTED_PACKET_TYPE;
             return buf;
     }
     /* Note that we have matched on packet_type! */
@@ -5963,7 +5965,7 @@  xlate_generic_decap_action(struct xlate_ctx *ctx,
                 /* Error handling: drop packet. */
                 xlate_report_debug(ctx, OFT_ACTION, "Dropping packet, cannot "
                                    "decap Ethernet if VLAN is present.");
-                ctx->error = 1;
+                ctx->error = XLATE_UNSUPPORTED_PACKET_TYPE;
             } else {
                 /* Just change the packet_type.
                  * Delay generating pop_eth to the next commit. */
@@ -5994,7 +5996,7 @@  xlate_generic_decap_action(struct xlate_ctx *ctx,
                 xlate_report_debug(ctx, OFT_ACTION,
                                    "Dropping packet as NSH next protocol %d "
                                    "is not supported", flow->nsh.np);
-                ctx->error = 1;
+                ctx->error = XLATE_UNSUPPORTED_PACKET_TYPE;
                 return false;
                 break;
             }
@@ -6008,7 +6010,7 @@  xlate_generic_decap_action(struct xlate_ctx *ctx,
                     "Dropping packet as the decap() does not support "
                     "packet type (%d,0x%x)",
                     pt_ns(flow->packet_type), pt_ns_type(flow->packet_type));
-            ctx->error = 1;
+            ctx->error = XLATE_UNSUPPORTED_PACKET_TYPE;
             return false;
     }
 }
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index a299d109f..39542de2b 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -211,6 +211,7 @@  enum xlate_error {
     XLATE_RECIRCULATION_CONFLICT,
     XLATE_TOO_MANY_MPLS_LABELS,
     XLATE_INVALID_TUNNEL_METADATA,
+    XLATE_UNSUPPORTED_PACKET_TYPE,
 };
 
 const char *xlate_strerror(enum xlate_error error);