diff mbox series

[ovs-dev,3/3] tc: Use sparse hex dump while printing inconsistencies.

Message ID 20220729143030.3227061-4-i.maximets@ovn.org
State Accepted
Commit 398623a63ed4f35e67292740466a99db018f75b6
Headers show
Series netdev-offload-tc: Improved debug logs for bad/unused bit masks. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Ilya Maximets July 29, 2022, 2:30 p.m. UTC
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 <i.maximets@ovn.org>
---
 lib/tc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Roi Dayan Aug. 1, 2022, 6:03 a.m. UTC | #1
On 2022-07-29 5:30 PM, Ilya Maximets wrote:
> 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 <i.maximets@ovn.org>
> ---
>   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

Reviewed-by: Roi Dayan <roid@nvidia.com>
diff mbox series

Patch

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