Format tunnel IDs consistently.
authorBen Pfaff <blp@nicira.com>
Wed, 1 Dec 2010 00:54:50 +0000 (16:54 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 3 Dec 2010 17:32:31 +0000 (09:32 -0800)
Some code failed to convert tunnel IDs to host byte order for printing,
so this fixes that.  Some code printed tunnel IDs with a 0x prefix and
other code didn't, so this code uses the '#' flag consistently (which
prints 0x for nonzero values and omits it for zero).

This commit also stops always printing all 8 digits.  When tunnel IDs
are expanded to 64 bits, as they will be soon, printing 16 digits all the
time wastes too much space.

Acked-by: Jesse Gross <jesse@nicira.com>
lib/flow.c
lib/odp-util.c
lib/ofp-print.c

index 8922562866e21dd72bdc5763bdef13169d2949f8..7198f7d71a0f4af544189e7ddce6f0a9976e4763 100644 (file)
@@ -261,7 +261,7 @@ flow_to_string(const struct flow *flow)
 void
 flow_format(struct ds *ds, const struct flow *flow)
 {
-    ds_put_format(ds, "tunnel%08"PRIx32":in_port%04"PRIx16":tci(",
+    ds_put_format(ds, "tunnel%#"PRIx32":in_port%04"PRIx16":tci(",
                   ntohl(flow->tun_id), flow->in_port);
     if (flow->vlan_tci) {
         ds_put_format(ds, "vlan%"PRIu16",pcp%d",
index 0c8caabb0c9014b9f550c53da182417bec72e7e2..6b4f5fada567e7c7c9a28e300f6c3d0cf718faf3 100644 (file)
@@ -42,8 +42,8 @@ odp_actions_add(struct odp_actions *actions, uint16_t type)
 void
 format_odp_flow_key(struct ds *ds, const struct odp_flow_key *key)
 {
-    ds_put_format(ds, "tun_id0x%08x in_port%d tci(",
-                  key->tun_id, key->in_port);
+    ds_put_format(ds, "tun_id%#"PRIx32" in_port%d tci(",
+                  ntohl(key->tun_id), key->in_port);
     if (key->dl_tci) {
         ds_put_format(ds, "vlan%"PRIu16",pcp%d",
                       vlan_tci_to_vid(key->dl_tci),
@@ -70,7 +70,7 @@ format_odp_action(struct ds *ds, const union odp_action *a)
         ds_put_format(ds, "ctl(%"PRIu32")", a->controller.arg);
         break;
     case ODPAT_SET_TUNNEL:
-        ds_put_format(ds, "set_tunnel(0x%08"PRIx32")", ntohl(a->tunnel.tun_id));
+        ds_put_format(ds, "set_tunnel(%#"PRIx32")", ntohl(a->tunnel.tun_id));
         break;
     case ODPAT_SET_DL_TCI:
         ds_put_format(ds, "set_tci(vid=%"PRIu16",pcp=%d)",
index 97fd0653d8c3ae5212420e3c35c03d1903fc2b00..eb7e534fe114665fa5fe5713b00ac67f2adeec35 100644 (file)
@@ -213,7 +213,7 @@ ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah)
     case NXAST_SET_TUNNEL: {
         const struct nx_action_set_tunnel *nast =
                                             (struct nx_action_set_tunnel *)nah;
-        ds_put_format(string, "set_tunnel:0x%08"PRIx32, ntohl(nast->tun_id));
+        ds_put_format(string, "set_tunnel:%#"PRIx32, ntohl(nast->tun_id));
         break;
     }