datapath: Clean up use of TBL_* constants.
[openvswitch] / lib / ofp-print.c
index e565569789742de5862445010966c9ad725417d5..d88a574cbb8eac69c42e25f340725082fcf8fd58 100644 (file)
@@ -30,6 +30,7 @@
 #include "compiler.h"
 #include "dynamic-string.h"
 #include "flow.h"
+#include "multipath.h"
 #include "nx-match.h"
 #include "ofp-util.h"
 #include "ofpbuf.h"
@@ -216,6 +217,7 @@ nx_action_len(enum nx_action_subtype subtype)
     case NXAST_REG_LOAD: return sizeof(struct nx_action_reg_load);
     case NXAST_NOTE: return -1;
     case NXAST_SET_TUNNEL64: return sizeof(struct nx_action_set_tunnel64);
+    case NXAST_MULTIPATH: return sizeof(struct nx_action_multipath);
     default: return -1;
     }
 }
@@ -240,6 +242,7 @@ ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah)
         const struct nx_action_resubmit *nar;
         const struct nx_action_reg_move *move;
         const struct nx_action_reg_load *load;
+        const struct nx_action_multipath *nam;
 
         switch ((enum nx_action_subtype) subtype) {
         case NXAST_RESUBMIT:
@@ -281,11 +284,16 @@ ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah)
             return;
 
         case NXAST_SET_TUNNEL64:
-            nast64 = (struct nx_action_set_tunnel64 *) nah;
+            nast64 = (const struct nx_action_set_tunnel64 *) nah;
             ds_put_format(string, "set_tunnel64:%#"PRIx64,
                           ntohll(nast64->tun_id));
             return;
 
+        case NXAST_MULTIPATH:
+            nam = (const struct nx_action_multipath *) nah;
+            multipath_format(nam, string);
+            return;
+
         case NXAST_SNAT__OBSOLETE:
         default:
             break;
@@ -1036,7 +1044,7 @@ ofp_print_error(struct ds *string, int error)
     if (string->length) {
         ds_put_char(string, ' ');
     }
-    ds_put_format(string, " ***decode error type:%d(%s) code:%d(%s)***",
+    ds_put_format(string, " ***decode error type:%d(%s) code:%d(%s)***\n",
                   type, lookup_error_type(type),
                   code, lookup_error_code(type, code));
 }
@@ -1720,14 +1728,17 @@ ofp_to_string(const void *oh_, size_t len, int verbosity)
     struct ds string = DS_EMPTY_INITIALIZER;
     const struct ofp_header *oh = oh_;
 
-    if (len < sizeof(struct ofp_header)) {
-        ds_put_cstr(&string, "OpenFlow packet too short:\n");
+    if (!len) {
+        ds_put_cstr(&string, "OpenFlow message is empty\n");
+    } else if (len < sizeof(struct ofp_header)) {
+        ds_put_format(&string, "OpenFlow packet too short (only %zu bytes):\n",
+                      len);
     } else if (oh->version != OFP_VERSION) {
         ds_put_format(&string, "Bad OpenFlow version %"PRIu8":\n",
                       oh->version);
     } else if (ntohs(oh->length) > len) {
         ds_put_format(&string,
-                      "(***truncated to %zu bytes from %"PRIu16"***)",
+                      "(***truncated to %zu bytes from %"PRIu16"***)\n",
                       len, ntohs(oh->length));
     } else if (ntohs(oh->length) < len) {
         ds_put_format(&string,