Instead of a very long hex string something like this will be printed:

 |DBG|tc flower compare failed mask compare:
 Expected Mask:
 00000000  ff ff 00 00 ff ff ff ff-ff ff ff ff ff ff ff ff
 00000020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 03 00
 00000090  00 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff
 000000c0  ff 00 00 00 ff ff 00 00-ff ff ff ff ff ff ff ff

 Received Mask:
 00000000  ff ff 00 00 ff ff ff ff-ff ff ff ff ff ff ff ff
 00000020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 03 00
 00000090  00 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff
 000000c0  ff 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff

It's easier to spot the difference this way and count which bytes are
to blame, since offsets are printed as well.

Using a sparse dump to avoid printing huge number of all-zero lines.

Signed-off-by: Ilya Maximets <[email protected]>
---
 lib/tc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/tc.c b/lib/tc.c
index 25e66b5c5..aaeb7708c 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -3599,17 +3599,17 @@ log_tc_flower_match(const char *msg,
         key_b[i] = ((uint8_t *) &b->key)[i] & mask_b;
     }
     ds_put_cstr(&s, "\nExpected Mask:\n");
-    ds_put_hex(&s, &a->mask, sizeof a->mask);
+    ds_put_sparse_hex_dump(&s, &a->mask, sizeof a->mask, 0, false);
     ds_put_cstr(&s, "\nReceived Mask:\n");
-    ds_put_hex(&s, &b->mask, sizeof b->mask);
+    ds_put_sparse_hex_dump(&s, &b->mask, sizeof b->mask, 0, false);
     ds_put_cstr(&s, "\nExpected Key:\n");
-    ds_put_hex(&s, &a->key, sizeof a->key);
+    ds_put_sparse_hex_dump(&s, &a->key, sizeof a->key, 0, false);
     ds_put_cstr(&s, "\nReceived Key:\n");
-    ds_put_hex(&s, &b->key, sizeof b->key);
+    ds_put_sparse_hex_dump(&s, &b->key, sizeof b->key, 0, false);
     ds_put_cstr(&s, "\nExpected Masked Key:\n");
-    ds_put_hex(&s, key_a, sizeof key_a);
+    ds_put_sparse_hex_dump(&s, key_a, sizeof key_a, 0, false);
     ds_put_cstr(&s, "\nReceived Masked Key:\n");
-    ds_put_hex(&s, key_b, sizeof key_b);
+    ds_put_sparse_hex_dump(&s, key_b, sizeof key_b, 0, false);
 
     if (a->action_count != b->action_count) {
         /* If action count is not equal, we print all actions to see which
-- 
2.34.3

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to