ofp-util: Treat a packet-out in_port of OFPP_CONTROLLER as OFPP_NONE.
[sliver-openvswitch.git] / lib / odp-util.c
index ffb486e..fef42ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -278,10 +278,16 @@ format_odp_actions(struct ds *ds, const struct nlattr *actions,
             format_odp_action(ds, a);
         }
         if (left) {
+            int i;
+
             if (left == actions_len) {
                 ds_put_cstr(ds, "<empty>");
             }
-            ds_put_format(ds, ",***%u leftover bytes***", left);
+            ds_put_format(ds, ",***%u leftover bytes*** (", left);
+            for (i = 0; i < left; i++) {
+                ds_put_format(ds, "%02x", ((const uint8_t *) a)[i]);
+            }
+            ds_put_char(ds, ')');
         }
     } else {
         ds_put_cstr(ds, "drop");
@@ -727,10 +733,16 @@ odp_flow_key_format(const struct nlattr *key, size_t key_len, struct ds *ds)
             format_odp_key_attr(a, ds);
         }
         if (left) {
+            int i;
+            
             if (left == key_len) {
                 ds_put_cstr(ds, "<empty>");
             }
-            ds_put_format(ds, ",***%u leftover bytes***", left);
+            ds_put_format(ds, ",***%u leftover bytes*** (", left);
+            for (i = 0; i < left; i++) {
+                ds_put_format(ds, "%02x", ((const uint8_t *) a)[i]);
+            }
+            ds_put_char(ds, ')');
         }
     } else {
         ds_put_cstr(ds, "<empty>");
@@ -1158,7 +1170,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow)
         nl_msg_put_be64(buf, OVS_KEY_ATTR_TUN_ID, flow->tun_id);
     }
 
-    if (flow->in_port != OFPP_NONE) {
+    if (flow->in_port != OFPP_NONE && flow->in_port != OFPP_CONTROLLER) {
         nl_msg_put_u32(buf, OVS_KEY_ATTR_IN_PORT,
                        ofp_port_to_odp_port(flow->in_port));
     }
@@ -1687,6 +1699,24 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len,
                            expected_attrs, flow, key, key_len);
 }
 
+/* Returns 'fitness' as a string, for use in debug messages. */
+const char *
+odp_key_fitness_to_string(enum odp_key_fitness fitness)
+{
+    switch (fitness) {
+    case ODP_FIT_PERFECT:
+        return "OK";
+    case ODP_FIT_TOO_MUCH:
+        return "too_much";
+    case ODP_FIT_TOO_LITTLE:
+        return "too_little";
+    case ODP_FIT_ERROR:
+        return "error";
+    default:
+        return "<unknown>";
+    }
+}
+
 /* Appends an OVS_ACTION_ATTR_USERSPACE action to 'odp_actions' that specifies
  * Netlink PID 'pid'.  If 'cookie' is nonnull, adds a userdata attribute whose
  * contents contains 'cookie' and returns the offset within 'odp_actions' of