Re: [PATCH iproute2-next v4 2/2] devlink: support u64-array values in devlink param show/set

From: David Ahern

Date: Wed Jul 08 2026 - 11:42:57 EST


On 7/1/26 9:13 PM, Ratheesh Kannoth wrote:
> diff --git a/devlink/devlink.c b/devlink/devlink.c
> index 803ea5d7..5d092d92 100644
> --- a/devlink/devlink.c
> +++ b/devlink/devlink.c
> @@ -3516,12 +3516,143 @@ static const struct param_val_conv param_val_conv[] = {
>
> #define PARAM_VAL_CONV_LEN ARRAY_SIZE(param_val_conv)
>
> +struct devlink_param_u64_array {
> + uint64_t size;

use of uint64_t here causes claude to comment:

Style 2: int i loop counter vs uint64_t size field in
param_value_u64_array_put_from_str() — signed/unsigned comparison.


> + uint64_t *val;
> +};
> +
> +static void param_value_u64_array_free(struct devlink_param_u64_array *arr)
> +{
> + free(arr->val);
> + arr->val = NULL;
> + arr->size = 0;
> +}
> +
> +static int param_value_nested_u64_attr_cb(const struct nlattr *attr, void *data)
> +{
> + struct devlink_param_u64_array *arr = data;
> + unsigned int len;
> + uint64_t val;
> + uint64_t *new_val;

iproute2 follows netdev coding style - reverse xmas tree.

other comments from claude:

Bug 1 (both cmd_dev_param_set and cmd_port_param_set): When the new and
current U64_ARRAY values are equal, param_value_u64_array_put_from_str()
returns 1 as a sentinel. The code jumps to out: but err is still 1, so
the function returns a non-zero error code to its caller even though
nothing went wrong. All other types reach goto out with err = 0 because
a prior mnlu_gen_socket_sndrcv() call succeeded. Fix: explicitly set err
= 0 before the goto.

Bug 2 (JSON output for U64_ARRAY in pr_out_param_value_print): The loop
calls print_u64(PRINT_ANY, label, ...) with the same key on every
iteration. In JSON mode this produces duplicate keys ("value": 0,
"value": 1, ...), which is invalid JSON. Needs
open_json_array()/close_json_array() wrapping the loop.

Style 1: flag_as_u8 is repurposed to select which netlink attribute to
parse for U64_ARRAY — its name is completely unrelated to this use,
making the code fragile.


Please show json output in the commit message as well.