odp-util: Print EtherTypes consistently.
authorJesse Gross <jesse@nicira.com>
Sun, 30 Jan 2011 07:41:27 +0000 (23:41 -0800)
committerJesse Gross <jesse@nicira.com>
Sun, 30 Jan 2011 07:41:27 +0000 (23:41 -0800)
The '#' format specifier doesn't respect the field width modifier,
so EtherTypes are printed with variable length.  Zero is not a valid
EtherType so there isn't a need for the logic to dynamically insert
the 0x prefix (if the EtherType isn't specified it won't be printed
at all).  This fixes the EtherType to have the intended format and
also changes the vlan TPID to match.

lib/odp-util.c

index c70ea35..e50b578 100644 (file)
@@ -266,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),
@@ -274,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;