ovs-vlan-test: clearly indicate failure.
[openvswitch] / lib / odp-util.c
index 193f97be0304d4137bc0d56450b52459254947b0..e50b57850498b636f3ed41435bf5a43ae1aa8b1a 100644 (file)
 int
 odp_action_len(uint16_t type)
 {
-    if (type > ODPAT_MAX) {
+    if (type > ODP_ACTION_ATTR_MAX) {
         return -1;
     }
 
     switch ((enum odp_action_type) type) {
-    case ODPAT_OUTPUT: return 4;
-    case ODPAT_CONTROLLER: return 8;
-    case ODPAT_SET_DL_TCI: return 2;
-    case ODPAT_STRIP_VLAN: return 0;
-    case ODPAT_SET_DL_SRC: return ETH_ADDR_LEN;
-    case ODPAT_SET_DL_DST: return ETH_ADDR_LEN;
-    case ODPAT_SET_NW_SRC: return 4;
-    case ODPAT_SET_NW_DST: return 4;
-    case ODPAT_SET_NW_TOS: return 1;
-    case ODPAT_SET_TP_SRC: return 2;
-    case ODPAT_SET_TP_DST: return 2;
-    case ODPAT_SET_TUNNEL: return 8;
-    case ODPAT_SET_PRIORITY: return 4;
-    case ODPAT_POP_PRIORITY: return 0;
-    case ODPAT_DROP_SPOOFED_ARP: return 0;
-
-    case ODPAT_UNSPEC:
-    case __ODPAT_MAX:
+    case ODP_ACTION_ATTR_OUTPUT: return 4;
+    case ODP_ACTION_ATTR_CONTROLLER: return 8;
+    case ODP_ACTION_ATTR_SET_DL_TCI: return 2;
+    case ODP_ACTION_ATTR_STRIP_VLAN: return 0;
+    case ODP_ACTION_ATTR_SET_DL_SRC: return ETH_ADDR_LEN;
+    case ODP_ACTION_ATTR_SET_DL_DST: return ETH_ADDR_LEN;
+    case ODP_ACTION_ATTR_SET_NW_SRC: return 4;
+    case ODP_ACTION_ATTR_SET_NW_DST: return 4;
+    case ODP_ACTION_ATTR_SET_NW_TOS: return 1;
+    case ODP_ACTION_ATTR_SET_TP_SRC: return 2;
+    case ODP_ACTION_ATTR_SET_TP_DST: return 2;
+    case ODP_ACTION_ATTR_SET_TUNNEL: return 8;
+    case ODP_ACTION_ATTR_SET_PRIORITY: return 4;
+    case ODP_ACTION_ATTR_POP_PRIORITY: return 0;
+    case ODP_ACTION_ATTR_DROP_SPOOFED_ARP: return 0;
+
+    case ODP_ACTION_ATTR_UNSPEC:
+    case __ODP_ACTION_ATTR_MAX:
         return -1;
     }
 
@@ -95,56 +95,56 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
     }
 
     switch (nl_attr_type(a)) {
-    case ODPAT_OUTPUT:
+    case ODP_ACTION_ATTR_OUTPUT:
         ds_put_format(ds, "%"PRIu16, nl_attr_get_u32(a));
         break;
-    case ODPAT_CONTROLLER:
+    case ODP_ACTION_ATTR_CONTROLLER:
         ds_put_format(ds, "ctl(%"PRIu64")", nl_attr_get_u64(a));
         break;
-    case ODPAT_SET_TUNNEL:
+    case ODP_ACTION_ATTR_SET_TUNNEL:
         ds_put_format(ds, "set_tunnel(%#"PRIx64")",
                       ntohll(nl_attr_get_be64(a)));
         break;
-    case ODPAT_SET_DL_TCI:
+    case ODP_ACTION_ATTR_SET_DL_TCI:
         ds_put_format(ds, "set_tci(vid=%"PRIu16",pcp=%d)",
                       vlan_tci_to_vid(nl_attr_get_be16(a)),
                       vlan_tci_to_pcp(nl_attr_get_be16(a)));
         break;
-    case ODPAT_STRIP_VLAN:
+    case ODP_ACTION_ATTR_STRIP_VLAN:
         ds_put_format(ds, "strip_vlan");
         break;
-    case ODPAT_SET_DL_SRC:
+    case ODP_ACTION_ATTR_SET_DL_SRC:
         eth = nl_attr_get_unspec(a, ETH_ADDR_LEN);
         ds_put_format(ds, "set_dl_src("ETH_ADDR_FMT")", ETH_ADDR_ARGS(eth));
         break;
-    case ODPAT_SET_DL_DST:
+    case ODP_ACTION_ATTR_SET_DL_DST:
         eth = nl_attr_get_unspec(a, ETH_ADDR_LEN);
         ds_put_format(ds, "set_dl_dst("ETH_ADDR_FMT")", ETH_ADDR_ARGS(eth));
         break;
-    case ODPAT_SET_NW_SRC:
+    case ODP_ACTION_ATTR_SET_NW_SRC:
         ip = nl_attr_get_be32(a);
         ds_put_format(ds, "set_nw_src("IP_FMT")", IP_ARGS(&ip));
         break;
-    case ODPAT_SET_NW_DST:
+    case ODP_ACTION_ATTR_SET_NW_DST:
         ip = nl_attr_get_be32(a);
         ds_put_format(ds, "set_nw_dst("IP_FMT")", IP_ARGS(&ip));
         break;
-    case ODPAT_SET_NW_TOS:
+    case ODP_ACTION_ATTR_SET_NW_TOS:
         ds_put_format(ds, "set_nw_tos(%"PRIu8")", nl_attr_get_u8(a));
         break;
-    case ODPAT_SET_TP_SRC:
+    case ODP_ACTION_ATTR_SET_TP_SRC:
         ds_put_format(ds, "set_tp_src(%"PRIu16")", ntohs(nl_attr_get_be16(a)));
         break;
-    case ODPAT_SET_TP_DST:
+    case ODP_ACTION_ATTR_SET_TP_DST:
         ds_put_format(ds, "set_tp_dst(%"PRIu16")", ntohs(nl_attr_get_be16(a)));
         break;
-    case ODPAT_SET_PRIORITY:
+    case ODP_ACTION_ATTR_SET_PRIORITY:
         ds_put_format(ds, "set_priority(%#"PRIx32")", nl_attr_get_u32(a));
         break;
-    case ODPAT_POP_PRIORITY:
+    case ODP_ACTION_ATTR_POP_PRIORITY:
         ds_put_cstr(ds, "pop_priority");
         break;
-    case ODPAT_DROP_SPOOFED_ARP:
+    case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
         ds_put_cstr(ds, "drop_spoofed_arp");
         break;
     default:
@@ -177,59 +177,6 @@ format_odp_actions(struct ds *ds, const struct nlattr *actions,
         ds_put_cstr(ds, "drop");
     }
 }
-
-void
-format_odp_flow_stats(struct ds *ds, const struct odp_flow_stats *s)
-{
-    ds_put_format(ds, "packets:%llu, bytes:%llu, used:",
-                  (unsigned long long int) s->n_packets,
-                  (unsigned long long int) s->n_bytes);
-    if (s->used_sec) {
-        long long int used = s->used_sec * 1000 + s->used_nsec / 1000000;
-        ds_put_format(ds, "%.3fs", (time_msec() - used) / 1000.0);
-    } else {
-        ds_put_format(ds, "never");
-    }
-}
-
-void
-format_odp_flow(struct ds *ds, const struct odp_flow *f)
-{
-    odp_flow_key_format(f->key, f->key_len, ds);
-    ds_put_cstr(ds, ", ");
-    format_odp_flow_stats(ds, &f->stats);
-    ds_put_cstr(ds, ", actions:");
-    format_odp_actions(ds, f->actions, f->actions_len);
-}
-
-void
-format_odp_port_type(struct ds *ds, const struct odp_port *p)
-{
-    if (!strcmp(p->type, "gre") 
-            || !strcmp(p->type, "ipsec_gre")
-            || !strcmp(p->type, "capwap")) {
-        const struct tnl_port_config *config;
-
-        config = (struct tnl_port_config *)p->config;
-
-        ds_put_format(ds, " (%s: remote_ip="IP_FMT, 
-                p->type, IP_ARGS(&config->daddr));
-
-        if (config->saddr) {
-            ds_put_format(ds, ", local_ip="IP_FMT, IP_ARGS(&config->saddr));
-        }
-
-        if (config->in_key) {
-            ds_put_format(ds, ", in_key=%#"PRIx64, ntohll(config->in_key));
-        }
-
-        ds_put_cstr(ds, ")");
-    } else if (!strcmp(p->type, "patch")) {
-        ds_put_format(ds, " (%s: peer=%s)", p->type, (char *)p->config);
-    } else if (strcmp(p->type, "system")) {
-        ds_put_format(ds, " (%s)", p->type);
-    }
-}
 \f
 /* Returns the correct length of the payload for a flow key attribute of the
  * specified 'type', or -1 if 'type' is unknown. */
@@ -319,7 +266,7 @@ format_odp_key_attr(const struct nlattr *a, struct ds *ds)
         q_key = nl_attr_get(a);
         ds_put_cstr(ds, "vlan(");
         if (q_key->q_tpid != htons(ETH_TYPE_VLAN)) {
-            ds_put_format(ds, "tpid=%#"PRIx16",", ntohs(q_key->q_tpid));
+            ds_put_format(ds, "tpid=0x%04"PRIx16",", ntohs(q_key->q_tpid));
         }
         ds_put_format(ds, "vid%"PRIu16",pcp%d)",
                       vlan_tci_to_vid(q_key->q_tci),
@@ -327,7 +274,7 @@ format_odp_key_attr(const struct nlattr *a, struct ds *ds)
         break;
 
     case ODP_KEY_ATTR_ETHERTYPE:
-        ds_put_format(ds, "eth_type(%#04"PRIx16")",
+        ds_put_format(ds, "eth_type(0x%04"PRIx16")",
                       ntohs(nl_attr_get_be16(a)));
         break;