Linux Netfilter development
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Georg Pfuetzenreuter <georg@syscid.com>
Cc: netfilter-devel@vger.kernel.org,
	Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
Subject: Re: [nftables PATCH] json: support element output
Date: Wed, 14 Jan 2026 16:15:49 +0100	[thread overview]
Message-ID: <aWezJQrNDkICYd2M@orbyte.nwl.cc> (raw)
In-Reply-To: <20251203131736.4036382-2-georg@syscid.com>

Hi Georg,

Sorry for the late reply, I missed your mail last year and am still
recovering from the "big reset". ;)

On Wed, Dec 03, 2025 at 02:17:36PM +0100, Georg Pfuetzenreuter wrote:
> From: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
> 
> JSON was skipped for `get element` operations. Resolve this by
> introducing JSON output handling for set elements - the structure is
> kept close to what's already implemented for `list set`.
> 
> Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>

Patch looks fine apart from:

[...]
> +int do_get_setelems_json(struct netlink_ctx *ctx, struct cmd *cmd, bool reset)
> +{
> +	struct set *set, *new_set;
> +	struct expr *init;
> +	json_t *root = json_array();
> +	int err;

Please stick to reverse christmas tree notation here, i.e. put the
json_t *root on top of the list.

> +
> +	set = cmd->elem.set;
> +
> +	if (set_is_non_concat_range(set))
> +		init = get_set_intervals(set, cmd->expr);
> +	else
> +		init = cmd->expr;
> +
> +	new_set = set_clone(set);
> +
> +	json_array_insert_new(root, 0, generate_json_metainfo());
> +
> +	err = netlink_get_setelem(ctx, &cmd->handle, &cmd->location,
> +				  cmd->elem.set, new_set, init, reset);
> +	if (err >= 0)
> +		json_array_append_new(root, set_print_json(&ctx->nft->output, new_set));

This line exceeds 80 columns, no?

Also, could you please add a test case? A simple one in
tests/shell/testcases/json/ to make sure 'nft -j get element' output is
as expected should be fine.

Thanks, Phil

      reply	other threads:[~2026-01-14 15:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 13:17 [nftables PATCH] json: support element output Georg Pfuetzenreuter
2026-01-14 15:15 ` Phil Sutter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWezJQrNDkICYd2M@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=georg.pfuetzenreuter@suse.com \
    --cc=georg@syscid.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox