On Sun, Jun 16, 2019 at 10:55:49AM +0200, Florian Westphal wrote:
> The two rules:
> arp operation 1-2 accept
> arp operation 256-512 accept
>
> are both shown as 256-512:
>
> chain in_public {
> arp operation 256-512 accept
> arp operation 256-512 accept
> meta mark "1"
> tcp flags 2,4
> }
>
> This is because range expression enforces numeric output,
> yet nft_print doesn't respect byte order.
>
> Behave as if we had no symbol in the first place and call
> the base type print function instead.
>
> This means we now respect format specifier as well:
> chain in_public {
> arp operation 1-2 accept
> arp operation 256-512 accept
> meta mark "0x00000001"
Hm, why is "1" turned into "0x00000001"?
I would expect quoted mark means: look at rt_marks.
Thanks!
> tcp flags 0x2,0x4
> }
> Without fix, added test case will fail:
> 'add rule arp test-arp input arp operation 1-2': 'arp operation 1-2'
> mismatches 'arp operation 256-512'
>
> Signed-off-by: Florian Westphal <[email protected]>
> ---
> Note there is a discrepancy between output when we have a symbol and
> when we do not.
>
> Example, add rule:
> meta mark "foo"
>
> (with '1 "foo"' in rt_marks), nft will print quotes when symbol
> printing is inhibited via -n, but elides them in case the symbol
> is not available.
Then, we also need a patch to regard NFT_CTX_OUTPUT_NUMERIC_ALL, right?
> src/datatype.c | 2 +-
> tests/py/arp/arp.t | 1 +
> tests/py/arp/arp.t.payload | 6 ++++++
> tests/py/arp/arp.t.payload.netdev | 8 ++++++++
> 4 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/datatype.c b/src/datatype.c
> index 8ae3aa1c3f90..d193ccc0a659 100644
> --- a/src/datatype.c
> +++ b/src/datatype.c
> @@ -198,7 +198,7 @@ void symbolic_constant_print(const struct symbol_table
> *tbl,
> nft_print(octx, "\"");
>
> if (nft_output_numeric_symbol(octx))
> - nft_print(octx, "%" PRIu64 "", val);
> + expr_basetype(expr)->print(expr, octx);
> else
> nft_print(octx, "%s", s->identifier);
>