From nobody Sat Feb 7 18:51:59 2026 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E42E9311C2D for ; Fri, 6 Feb 2026 21:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770412294; cv=none; b=cgTr11UJXNetWFcyggBsKf5twOr8/nx0fJunaKDx6dnijLqEHqmA5/KXTeUWHNAGlkphbaEjYNE6edKUIqbED3iMakwL7zb3+3USMza7RpkUSh4L9OHS1e+ynaOJuEdITfgtsmopmFjVfLo1qyTldQUdx9n5C4B0Qe30T23COzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770412294; c=relaxed/simple; bh=ZJGt5PZM/nN3kZTykMYBSMrst9tts/dfMPeqZox+nFI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AY7hht2rvxc40kPoT1SqXTQL8AQVq2GxmyEdh3XCK/dx1UfJhe4dkUn96embUwPgn2hkpawMTCkh8POi2hdyOmnqmjz5dl4ZtzRPtlxHq+V40wc0lg0zuhWjOTG9r0iDsyAXFYMa32+m03WcsL3ib4+FGSpXmwbM13dWgWJvh9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iBh4+y/o; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iBh4+y/o" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-79628fb5c05so4705117b3.2 for ; Fri, 06 Feb 2026 13:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770412293; x=1771017093; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=y3mrRd/DcSc3QJ3DMZSsD+xWxAcjq5y0z1Z50HIA9dk=; b=iBh4+y/omRzhorSMH1GWOJWS/CvDJ8jlUL8t2FA1Hgo7gXuPN4BWgFudTcK74pJNCZ XwwvkIx78dxcbbSa8XD8XZiX+Z7116jcS6nD1j5x4zQqVwVl3GAyE+8nUfGxP7flUSek n2vAWM7v/0GHWG2kffRtcwJWokVtLRkacbuCm+mgHT6uG6kgQnNClyDetic/spm7CWWj NWIKqs9lMzgudWUV1j/N3b7HYDCgTQHS8u8r90XqmI3g8KptzLXK6GWM0uk/VuQLCQHG 8Py02AwTqS8a+OoBcxEg6KhGFwdfbVo0UQAC8WTl91/Wg5xGkBaeLRyKg8S4FaCAMwVw 0wEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770412293; x=1771017093; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=y3mrRd/DcSc3QJ3DMZSsD+xWxAcjq5y0z1Z50HIA9dk=; b=ssq1pYHuvp1BlHpHzBIXwqiUWek+lyTIwXOQkw1dBA1YYIPSFGWagC16JSas6nZtZa Uoq2KQQLp7bwYeUgvL0PjZgr7ICCgkYKtqQ8BZ0vsnpsVj5TRGoOG8Quuer0jYjiq4Zs re1s2kV3AyNneEzM35tUoSLB56E5XOg5+tCczWA+J/sqOWBVbhmaY0DDpdpvKC1s/LWt bMXQGKknlUokID57wk2VKMxLzXst8TBRV7Qi7LuSCoGC4Omssy8/O8H9EqLLemv8yWkd C+gNhUQUk4uRPCQnHbB8tAz5+8wotjo7aGFMJ3VP39zafrdVcbEwRcEPoKRZj52g9v5b Dm7g== X-Forwarded-Encrypted: i=1; AJvYcCU4pRKnOyOAHdaGvZ0JrqL1NdP6l30CCRiUzsBDB6Id151dSJ1TDRpmypPLOTJ0LRz+ElVBcgkEuQHzsf0=@vger.kernel.org X-Gm-Message-State: AOJu0YxeEaoranvNBzj+Vrm50k1I3BdZjDh/v+EwErG6/o1JEjR7mR+L EB7k+jnZ8nJgRgG6By/XHfk2Rz+o1XLUJ4V0YP2H53lup4JDHs0MsM7c X-Gm-Gg: AZuq6aKXS0Y8BcmrhbbSC2sGLWo54EINd63Z+sJ00bHQSM1gWQ5zNJum/rRROqvFtkX 343vIqY5CZtARrIVc3VNmZ4uHKO0dh7AnLRVJRjcoS2S5N4VfcVrIAjJSHT8w/rs9sou1fvnhq9 zqUQuztkbLuLbTuKCLBndR0rG0avVuuUSgmIew/kLtjccnRR48sR69HeVM9tqWPc+RtiEx86wyc y7/qIpDJs108iBJp44BvG+BNsl0VGcvJePgUag4On354pCGViF6hwoHPwTHIX0TIv6RfjgsWEmm 6EFlbOz/zzi/NHmCWmODF0JvS9KwrqJeS29x9uKBsfQ9c0KBEpwDPAQhRj141mdKxCFUKrswAPe +hWDJErtdgbkR4maJQit+efkYLa09N3xg0YKxrGvrR7bNgS8/UaJrrOzKnqOif98UwpItjE+pQD Tg1dGYYUeI X-Received: by 2002:a05:690c:38b:b0:794:c8da:d2db with SMTP id 00721157ae682-7952ab5a4b8mr39818707b3.52.1770412292698; Fri, 06 Feb 2026 13:11:32 -0800 (PST) Received: from localhost ([2a03:2880:25ff:5b::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7952a012af9sm32452877b3.4.2026.02.06.13.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 13:11:32 -0800 (PST) From: Daniel Zahka Date: Fri, 06 Feb 2026 13:11:30 -0800 Subject: [PATCH iproute2-next v2 2/2] devlink: support displaying and resetting to default params Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260206-param-defaults-v2-2-1ce78e2c5a31@gmail.com> References: <20260206-param-defaults-v2-0-1ce78e2c5a31@gmail.com> In-Reply-To: <20260206-param-defaults-v2-0-1ce78e2c5a31@gmail.com> To: Jiri Pirko , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Donald Hunter , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Zahka X-Mailer: b4 0.13.0 Add devlink cli support for default param values. For param-get, any default values provided by the kernel will be displayed next to the current value. For param-set, DEVLINK_ATTR_PARAM_RESET_DEFAULT can be included in the request to request that the parameter be reset to its default value. Default values of type bool are encoded with a u8 by the kernel to distinguish "false" from "not present". Signed-off-by: Daniel Zahka --- devlink/devlink.c | 54 ++++++++++++++++++++++++++++++++++++++++++++--= ---- man/man8/devlink-dev.8 | 22 ++++++++++++++++++-- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 81739291..39b0fac0 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -313,6 +313,7 @@ static int ifname_map_update(struct ifname_map *ifname_= map, const char *ifname) #define DL_OPT_PORT_FN_MAX_IO_EQS BIT(58) #define DL_OPT_PORT_FN_RATE_TC_BWS BIT(59) #define DL_OPT_HEALTH_REPORTER_BURST_PERIOD BIT(60) +#define DL_OPT_PARAM_SET_DEFAULT BIT(61) =20 struct dl_opts { uint64_t present; /* flags of present items */ @@ -2011,6 +2012,10 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_r= equired, if (err) return err; o_found |=3D DL_OPT_PARAM_CMODE; + } else if (dl_argv_match(dl, "default") && + (o_all & DL_OPT_PARAM_SET_DEFAULT)) { + dl_arg_inc(dl); + o_found |=3D DL_OPT_PARAM_SET_DEFAULT; } else if (dl_argv_match(dl, "snapshot") && (o_all & DL_OPT_REGION_SNAPSHOT_ID)) { dl_arg_inc(dl); @@ -2672,6 +2677,8 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct = dl *dl) if (opts->present & DL_OPT_PARAM_CMODE) mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_VALUE_CMODE, opts->cmode); + if (opts->present & DL_OPT_PARAM_SET_DEFAULT) + mnl_attr_put(nlh, DEVLINK_ATTR_PARAM_RESET_DEFAULT, 0, NULL); if (opts->present & DL_OPT_REGION_SNAPSHOT_ID) mnl_attr_put_u32(nlh, DEVLINK_ATTR_REGION_SNAPSHOT_ID, opts->region_snapshot_id); @@ -2839,7 +2846,7 @@ static void cmd_dev_help(void) pr_err(" [ inline-mode { none | link | netw= ork | transport } ]\n"); pr_err(" [ encap-mode { none | basic } ]\n"= ); pr_err(" devlink dev eswitch show DEV\n"); - pr_err(" devlink dev param set DEV name PARAMETER value VALUE cmode= { permanent | driverinit | runtime }\n"); + pr_err(" devlink dev param set DEV name PARAMETER [ value VALUE | d= efault ] cmode { permanent | driverinit | runtime }\n"); pr_err(" devlink dev param show [DEV name PARAMETER]\n"); pr_err(" devlink dev reload DEV [ netns { PID | NAME | ID } ]\n"); pr_err(" [ action { driver_reinit | fw_activ= ate } ] [ limit no_reset ]\n"); @@ -3504,7 +3511,7 @@ static const struct param_val_conv param_val_conv[] = =3D { =20 static int pr_out_param_value_print(const char *nla_name, int nla_type, struct nlattr *val_attr, bool conv_exists, - const char *label) + const char *label, bool flag_as_u8) { const char *vstr; int err; @@ -3562,7 +3569,11 @@ static int pr_out_param_value_print(const char *nla_= name, int nla_type, mnl_attr_get_str(val_attr)); break; case MNL_TYPE_FLAG: - print_bool(PRINT_ANY, label, "%s", val_attr); + if (flag_as_u8) + print_bool(PRINT_ANY, label, "%s", + mnl_attr_get_u8(val_attr)); + else + print_bool(PRINT_ANY, label, "%s", val_attr); break; } =20 @@ -3595,7 +3606,18 @@ static void pr_out_param_value(struct dl *dl, const = char *nla_name, conv_exists =3D param_val_conv_exists(param_val_conv, PARAM_VAL_CONV_LEN, nla_name); =20 - pr_out_param_value_print(nla_name, nla_type, val_attr, conv_exists, "valu= e"); + err =3D pr_out_param_value_print(nla_name, nla_type, val_attr, + conv_exists, "value", false); + if (err) + return; + + val_attr =3D nla_value[DEVLINK_ATTR_PARAM_VALUE_DEFAULT]; + if (val_attr) { + err =3D pr_out_param_value_print(nla_name, nla_type, val_attr, + conv_exists, "default", true); + if (err) + return; + } } =20 static void pr_out_param(struct dl *dl, struct nlattr **tb, bool array, @@ -3764,11 +3786,23 @@ static int cmd_dev_param_set(struct dl *dl) =20 err =3D dl_argv_parse(dl, DL_OPT_HANDLE | DL_OPT_PARAM_NAME | - DL_OPT_PARAM_VALUE | - DL_OPT_PARAM_CMODE, 0); + DL_OPT_PARAM_CMODE, + DL_OPT_PARAM_VALUE | DL_OPT_PARAM_SET_DEFAULT); if (err) return err; =20 + if ((dl->opts.present & DL_OPT_PARAM_VALUE) && + (dl->opts.present & DL_OPT_PARAM_SET_DEFAULT)) { + pr_err("Cannot specify both value and default\n"); + return -EINVAL; + } + + if (!(dl->opts.present & DL_OPT_PARAM_VALUE) && + !(dl->opts.present & DL_OPT_PARAM_SET_DEFAULT)) { + pr_err("Either value or default must be specified\n"); + return -EINVAL; + } + /* Get value type */ nlh =3D mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_PARAM_GET, NLM_F_REQUEST | NLM_F_ACK); @@ -3783,6 +3817,14 @@ static int cmd_dev_param_set(struct dl *dl) return -ENOTSUP; } =20 + if (dl->opts.present & DL_OPT_PARAM_SET_DEFAULT) { + nlh =3D mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_PARAM_SET, + NLM_F_REQUEST | NLM_F_ACK); + dl_opts_put(nlh, dl); + mnl_attr_put_u8(nlh, DEVLINK_ATTR_PARAM_TYPE, ctx.nla_type); + return mnlu_gen_socket_sndrcv(&dl->nlg, nlh, NULL, NULL); + } + nlh =3D mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_PARAM_SET, NLM_F_REQUEST | NLM_F_ACK); dl_opts_put(nlh, dl); diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8 index d10b1f9a..ad65f6f8 100644 --- a/man/man8/devlink-dev.8 +++ b/man/man8/devlink-dev.8 @@ -45,8 +45,12 @@ devlink-dev \- devlink device configuration .I DEV .B name .I PARAMETER +[ .B value .I VALUE +| +.B default +] .BR cmode " { " runtime " | " driverinit " | " permanent " } " =20 .ti -8 @@ -159,7 +163,13 @@ Specify parameter name to set. =20 .TP .BI value " VALUE" -New value to set. +New value to set. Mutually exclusive with +.BR default . + +.TP +.B default +Restore parameter to its default value. Mutually exclusive with +.BR value . =20 .TP .BR cmode " { " runtime " | " driverinit " | " permanent " } " @@ -176,10 +186,13 @@ Configuration mode in which the new value is set. =20 .SS devlink dev param show - display devlink device supported configuratio= n parameters attributes =20 +.TP .B name .I PARAMETER Specify parameter name to show. If this argument is omitted all parameters supported by devlink devices ar= e listed. +When the kernel provides a default value for a parameter, it will be autom= atically displayed +in the output alongside the current value. =20 .SS devlink dev reload - perform hot reload of the driver. =20 @@ -309,7 +322,7 @@ Sets the eswitch mode of specified devlink device to sw= itchdev. .PP devlink dev param show pci/0000:01:00.0 name max_macs .RS 4 -Shows the parameter max_macs attributes. +Shows the parameter max_macs attributes. If a default value exists, it wil= l be displayed alongside the current value. .RE .PP devlink dev param set pci/0000:01:00.0 name internal_error_reset value tru= e cmode runtime @@ -317,6 +330,11 @@ devlink dev param set pci/0000:01:00.0 name internal_e= rror_reset value true cmod Sets the parameter internal_error_reset of specified devlink device to tru= e. .RE .PP +devlink dev param set pci/0000:01:00.0 name internal_error_reset default c= mode runtime +.RS 4 +Restores the parameter internal_error_reset of specified devlink device to= its default value. +.RE +.PP devlink dev reload pci/0000:01:00.0 .RS 4 Performs hot reload of specified devlink device. --=20 2.47.3