All of lore.kernel.org
 help / color / mirror / Atom feed
* [iproute2-next v3 0/3] devlink: support dry run attribute for flash update
@ 2022-07-25 20:56 Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 1/3] update <linux/devlink.h> UAPI header Jacob Keller
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jacob Keller @ 2022-07-25 20:56 UTC (permalink / raw)
  To: netdev
  Cc: Jacob Keller, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Allow users to request a dry run of a flash update by adding the
DEVLINK_ATTR_DRY_RUN.

Because many devlink commands do not validate and reject unknown attributes,
this could have unexpected side effects on older kernels which lack the
attribute. To handle this, check the socket and determine the maximum
attribute the kernel supports. Only allow passing the DEVLINK_ATTR_DRY_RUN
for kernels which have the attribute.

This allows a user to validate that a flash update will be accepted by the
driver and device without being forced to commit to updating.

Changes since v1
* Add Cc for maintainers
* Make dl_kernel_supports_dry_run more generic

Changes since v2
* Remove unnecessary () with return
* Reduce indentation of dl_get_max_attr

Cc: Jacob Keller <jacob.e.keller@intel.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Jiri Pirko <jiri@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: David Ahern <dsahern@kernel.org>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: linux-doc@vger.kernel.org
Cc: netdev@vger.kernel.org

Jacob Keller (3):
  update <linux/devlink.h> UAPI header
  mnlg: add function to get CTRL_ATTR_MAXATTR value
  devlink: add dry run attribute support to devlink flash

 devlink/devlink.c            | 46 +++++++++++++++++++++++++++--
 devlink/mnlg.c               | 56 ++++++++++++++++++++++++++++++++++++
 devlink/mnlg.h               |  1 +
 include/uapi/linux/devlink.h |  8 ++++++
 4 files changed, 109 insertions(+), 2 deletions(-)


base-commit: 4cb0bec3744ac4f8d21de0e769f170e4059c6b9e
-- 
2.35.1.456.ga9c7032d4631


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [iproute2-next v3 1/3] update <linux/devlink.h> UAPI header
  2022-07-25 20:56 [iproute2-next v3 0/3] devlink: support dry run attribute for flash update Jacob Keller
@ 2022-07-25 20:56 ` Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash Jacob Keller
  2 siblings, 0 replies; 11+ messages in thread
From: Jacob Keller @ 2022-07-25 20:56 UTC (permalink / raw)
  To: netdev
  Cc: Jacob Keller, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 include/uapi/linux/devlink.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index da0f1ba8f7a0..90f6cf97d308 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -576,6 +576,14 @@ enum devlink_attr {
 	DEVLINK_ATTR_LINECARD_TYPE,		/* string */
 	DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES,	/* nested */
 
+	/* Before adding this attribute to a command, user space should check
+	 * the policy dump and verify the kernel recognizes the attribute.
+	 * Otherwise older kernels which do not recognize the attribute may
+	 * silently accept the unknown attribute while not actually performing
+	 * a dry run.
+	 */
+	DEVLINK_ATTR_DRY_RUN,			/* flag */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
-- 
2.35.1.456.ga9c7032d4631


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value
  2022-07-25 20:56 [iproute2-next v3 0/3] devlink: support dry run attribute for flash update Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 1/3] update <linux/devlink.h> UAPI header Jacob Keller
@ 2022-07-25 20:56 ` Jacob Keller
  2022-07-26  7:46   ` Jiri Pirko
  2022-07-25 20:56 ` [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash Jacob Keller
  2 siblings, 1 reply; 11+ messages in thread
From: Jacob Keller @ 2022-07-25 20:56 UTC (permalink / raw)
  To: netdev
  Cc: Jacob Keller, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Add a new function to extract the CTRL_ATTR_MAXATTR attribute of the
CTRL_CMD_GETFAMILY request. This will be used to allow reading the
maximum supported devlink attribute of the running kernel in an upcoming
change.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 devlink/mnlg.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 devlink/mnlg.h |  1 +
 2 files changed, 57 insertions(+)

diff --git a/devlink/mnlg.c b/devlink/mnlg.c
index e6d92742c150..348c3ff5c959 100644
--- a/devlink/mnlg.c
+++ b/devlink/mnlg.c
@@ -41,6 +41,10 @@ struct group_info {
 	const char *name;
 };
 
+struct family_info {
+	uint32_t max_attr;
+};
+
 static int parse_mc_grps_cb(const struct nlattr *attr, void *data)
 {
 	const struct nlattr **tb = data;
@@ -149,6 +153,58 @@ int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
 	return 0;
 }
 
+static int get_family_attr_cb(const struct nlattr *attr, void *data)
+{
+	const struct nlattr **tb = data;
+	int type = mnl_attr_get_type(attr);
+
+	if (mnl_attr_type_valid(attr, CTRL_ATTR_MAX) < 0)
+		return MNL_CB_ERROR;
+
+	tb[type] = attr;
+	return MNL_CB_OK;
+}
+
+static int get_family_cb(const struct nlmsghdr *nlh, void *data)
+{
+	struct family_info *family = data;
+	struct nlattr *tb[CTRL_ATTR_MAX + 1] = {};
+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+
+	mnl_attr_parse(nlh, sizeof(*genl), get_family_attr_cb, tb);
+	if (!tb[CTRL_ATTR_MAXATTR])
+		return MNL_CB_ERROR;
+
+	family->max_attr = mnl_attr_get_u32(tb[CTRL_ATTR_MAXATTR]);
+
+	return MNL_CB_OK;
+}
+
+int mnlg_socket_get_max_attr(struct mnlu_gen_socket *nlg, uint32_t *max_attr)
+{
+	struct nlmsghdr *nlh;
+	struct family_info family;
+	int err;
+
+	nlh = _mnlu_gen_socket_cmd_prepare(nlg, CTRL_CMD_GETFAMILY,
+					   NLM_F_REQUEST | NLM_F_ACK,
+					   GENL_ID_CTRL, 1);
+
+	mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, nlg->family);
+
+	err = mnlg_socket_send(nlg, nlh);
+	if (err < 0)
+		return err;
+
+	err = mnlu_gen_socket_recv_run(nlg, get_family_cb, &family);
+	if (err < 0)
+		return err;
+
+	*max_attr = family.max_attr;
+
+	return 0;
+}
+
 int mnlg_socket_get_fd(struct mnlu_gen_socket *nlg)
 {
 	return mnl_socket_get_fd(nlg->nl);
diff --git a/devlink/mnlg.h b/devlink/mnlg.h
index 24aa17566a9b..6348ad45ed26 100644
--- a/devlink/mnlg.h
+++ b/devlink/mnlg.h
@@ -18,6 +18,7 @@ struct mnlu_gen_socket;
 
 int mnlg_socket_send(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh);
 int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name);
+int mnlg_socket_get_max_attr(struct mnlu_gen_socket *nlg, uint32_t *max_attr);
 int mnlg_socket_get_fd(struct mnlu_gen_socket *nlg);
 
 #endif /* _MNLG_H_ */
-- 
2.35.1.456.ga9c7032d4631


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash
  2022-07-25 20:56 [iproute2-next v3 0/3] devlink: support dry run attribute for flash update Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 1/3] update <linux/devlink.h> UAPI header Jacob Keller
  2022-07-25 20:56 ` [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value Jacob Keller
@ 2022-07-25 20:56 ` Jacob Keller
  2022-07-25 21:13   ` Stephen Hemminger
  2022-07-26  7:47   ` Jiri Pirko
  2 siblings, 2 replies; 11+ messages in thread
From: Jacob Keller @ 2022-07-25 20:56 UTC (permalink / raw)
  To: netdev
  Cc: Jacob Keller, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Recent versions of the kernel support the DEVLINK_ATTR_DRY_RUN attribute
which allows requesting a dry run of a command. A dry run is simply
a request to validate that a command would work, without performing any
destructive changes.

The attribute is supported by the devlink flash update as a way to
validate an update, including potentially the binary image, without
modifying the device.

Add a "dry_run" option to the command line parsing which will enable
this attribute when requested.

To avoid potential issues, only allow the attribute to be added to
commands when the kernel recognizes it. This is important because some
commands do not perform strict validation. If we were to add the
attribute without this check, an old kernel may silently accept the
command and perform an update even when dry_run was requested.

Before adding the attribute, check the maximum attribute from the
CTRL_CMD_GETFAMILY and make sure that the kernel recognizes the
DEVLINK_ATTR_DRY_RUN attribute.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
Changes since v2
* Remove unnecessary () with return
* Reduce indentation of dl_get_max_attr

 devlink/devlink.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 1e2cfc3d4285..343ad98d9c7f 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -296,6 +296,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
 #define DL_OPT_PORT_FN_RATE_PARENT	BIT(51)
 #define DL_OPT_LINECARD		BIT(52)
 #define DL_OPT_LINECARD_TYPE	BIT(53)
+#define DL_OPT_DRY_RUN			BIT(54)
 
 struct dl_opts {
 	uint64_t present; /* flags of present items */
@@ -372,6 +373,8 @@ struct dl {
 	bool verbose;
 	bool stats;
 	bool hex;
+	bool max_attr_valid;
+	uint32_t max_attr;
 	struct {
 		bool present;
 		char *bus_name;
@@ -701,6 +704,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_LINECARD_STATE] = MNL_TYPE_U8,
 	[DEVLINK_ATTR_LINECARD_TYPE] = MNL_TYPE_STRING,
 	[DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_DRY_RUN] = MNL_TYPE_FLAG,
 };
 
 static const enum mnl_attr_data_type
@@ -1522,6 +1526,31 @@ static int dl_args_finding_required_validate(uint64_t o_required,
 	return 0;
 }
 
+static void dl_get_max_attr(struct dl *dl)
+{
+	uint32_t max_attr;
+	int err;
+
+	if (dl->max_attr_valid)
+		return;
+
+	err = mnlg_socket_get_max_attr(&dl->nlg, &max_attr);
+	if (err) {
+		pr_err("Unable to determine maximum supported devlink attribute\n");
+		return;
+	}
+
+	dl->max_attr = max_attr;
+	dl->max_attr_valid = true;
+}
+
+static bool dl_kernel_supports_attr(struct dl *dl, enum devlink_attr attr)
+{
+	dl_get_max_attr(dl);
+
+	return dl->max_attr_valid && dl->max_attr >= attr;
+}
+
 static int dl_argv_parse(struct dl *dl, uint64_t o_required,
 			 uint64_t o_optional)
 {
@@ -2037,6 +2066,16 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
 			dl_arg_inc(dl);
 			opts->linecard_type = "";
 			o_found |= DL_OPT_LINECARD_TYPE;
+		} else if (dl_argv_match(dl, "dry_run") &&
+			   (o_all & DL_OPT_DRY_RUN)) {
+
+			if (!dl_kernel_supports_attr(dl, DEVLINK_ATTR_DRY_RUN)) {
+				pr_err("Kernel does not support dry_run attribute\n");
+				return -EOPNOTSUPP;
+			}
+
+			dl_arg_inc(dl);
+			o_found |= DL_OPT_DRY_RUN;
 		} else {
 			pr_err("Unknown option \"%s\"\n", dl_argv(dl));
 			return -EINVAL;
@@ -2115,6 +2154,8 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME,
 				  opts->rate_node_name);
 	}
+	if (opts->present & DL_OPT_DRY_RUN)
+		mnl_attr_put(nlh, DEVLINK_ATTR_DRY_RUN, 0, NULL);
 	if (opts->present & DL_OPT_PORT_TYPE)
 		mnl_attr_put_u16(nlh, DEVLINK_ATTR_PORT_TYPE,
 				 opts->port_type);
@@ -2326,7 +2367,7 @@ static void cmd_dev_help(void)
 	pr_err("       devlink dev reload DEV [ netns { PID | NAME | ID } ]\n");
 	pr_err("                              [ action { driver_reinit | fw_activate } ] [ limit no_reset ]\n");
 	pr_err("       devlink dev info [ DEV ]\n");
-	pr_err("       devlink dev flash DEV file PATH [ component NAME ] [ overwrite SECTION ]\n");
+	pr_err("       devlink dev flash DEV file PATH [ component NAME ] [ overwrite SECTION ] [ dry_run ]\n");
 }
 
 static bool cmp_arr_last_handle(struct dl *dl, const char *bus_name,
@@ -3886,7 +3927,8 @@ static int cmd_dev_flash(struct dl *dl)
 			       NLM_F_REQUEST | NLM_F_ACK);
 
 	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE | DL_OPT_FLASH_FILE_NAME,
-				DL_OPT_FLASH_COMPONENT | DL_OPT_FLASH_OVERWRITE);
+				DL_OPT_FLASH_COMPONENT | DL_OPT_FLASH_OVERWRITE |
+				DL_OPT_DRY_RUN);
 	if (err)
 		return err;
 
-- 
2.35.1.456.ga9c7032d4631


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash
  2022-07-25 20:56 ` [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash Jacob Keller
@ 2022-07-25 21:13   ` Stephen Hemminger
  2022-07-25 21:19     ` Keller, Jacob E
  2022-07-25 21:27     ` Keller, Jacob E
  2022-07-26  7:47   ` Jiri Pirko
  1 sibling, 2 replies; 11+ messages in thread
From: Stephen Hemminger @ 2022-07-25 21:13 UTC (permalink / raw)
  To: Jacob Keller
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, linux-doc

On Mon, 25 Jul 2022 13:56:50 -0700
Jacob Keller <jacob.e.keller@intel.com> wrote:

> To avoid potential issues, only allow the attribute to be added to
> commands when the kernel recognizes it. This is important because some
> commands do not perform strict validation. If we were to add the
> attribute without this check, an old kernel may silently accept the
> command and perform an update even when dry_run was requested.

Sigh. Looks like the old kernels are buggy. The workaround in userspace
is also likely to be source of bugs.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash
  2022-07-25 21:13   ` Stephen Hemminger
@ 2022-07-25 21:19     ` Keller, Jacob E
  2022-07-25 21:27     ` Keller, Jacob E
  1 sibling, 0 replies; 11+ messages in thread
From: Keller, Jacob E @ 2022-07-25 21:19 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nguyen, Anthony L,
	David Ahern, linux-doc



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, July 25, 2022 2:13 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: netdev@vger.kernel.org; Jonathan Corbet <corbet@lwn.net>; Jiri Pirko
> <jiri@nvidia.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> David Ahern <dsahern@kernel.org>; linux-doc@vger.kernel.org
> Subject: Re: [iproute2-next v3 3/3] devlink: add dry run attribute support to
> devlink flash
> 
> On Mon, 25 Jul 2022 13:56:50 -0700
> Jacob Keller <jacob.e.keller@intel.com> wrote:
> 
> > To avoid potential issues, only allow the attribute to be added to
> > commands when the kernel recognizes it. This is important because some
> > commands do not perform strict validation. If we were to add the
> > attribute without this check, an old kernel may silently accept the
> > command and perform an update even when dry_run was requested.
> 
> Sigh. Looks like the old kernels are buggy. The workaround in userspace
> is also likely to be source of bugs.

We've known about this problem for a while.. I think its more complicated than just switching to strict validation, since ideally we want to validate attributes for each command separately, and not just accepting all known attributes for a given command.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash
  2022-07-25 21:13   ` Stephen Hemminger
  2022-07-25 21:19     ` Keller, Jacob E
@ 2022-07-25 21:27     ` Keller, Jacob E
  1 sibling, 0 replies; 11+ messages in thread
From: Keller, Jacob E @ 2022-07-25 21:27 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nguyen, Anthony L,
	David Ahern, linux-doc



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, July 25, 2022 2:13 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: netdev@vger.kernel.org; Jonathan Corbet <corbet@lwn.net>; Jiri Pirko
> <jiri@nvidia.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> David Ahern <dsahern@kernel.org>; linux-doc@vger.kernel.org
> Subject: Re: [iproute2-next v3 3/3] devlink: add dry run attribute support to
> devlink flash
> 
> On Mon, 25 Jul 2022 13:56:50 -0700
> Jacob Keller <jacob.e.keller@intel.com> wrote:
> 
> > To avoid potential issues, only allow the attribute to be added to
> > commands when the kernel recognizes it. This is important because some
> > commands do not perform strict validation. If we were to add the
> > attribute without this check, an old kernel may silently accept the
> > command and perform an update even when dry_run was requested.
> 
> Sigh. Looks like the old kernels are buggy. The workaround in userspace
> is also likely to be source of bugs.

There is also further discussion going on around this topic at https://lore.kernel.org/netdev/SA2PR11MB510047D98AFFDEE572B375E0D6959@SA2PR11MB5100.namprd11.prod.outlook.com/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value
  2022-07-25 20:56 ` [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value Jacob Keller
@ 2022-07-26  7:46   ` Jiri Pirko
  2022-08-26  0:40     ` Keller, Jacob E
  0 siblings, 1 reply; 11+ messages in thread
From: Jiri Pirko @ 2022-07-26  7:46 UTC (permalink / raw)
  To: Jacob Keller
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Mon, Jul 25, 2022 at 10:56:49PM CEST, jacob.e.keller@intel.com wrote:
>Add a new function to extract the CTRL_ATTR_MAXATTR attribute of the
>CTRL_CMD_GETFAMILY request. This will be used to allow reading the
>maximum supported devlink attribute of the running kernel in an upcoming
>change.
>
>Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash
  2022-07-25 20:56 ` [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash Jacob Keller
  2022-07-25 21:13   ` Stephen Hemminger
@ 2022-07-26  7:47   ` Jiri Pirko
  1 sibling, 0 replies; 11+ messages in thread
From: Jiri Pirko @ 2022-07-26  7:47 UTC (permalink / raw)
  To: Jacob Keller
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tony Nguyen,
	David Ahern, Stephen Hemminger, linux-doc

Mon, Jul 25, 2022 at 10:56:50PM CEST, jacob.e.keller@intel.com wrote:
>Recent versions of the kernel support the DEVLINK_ATTR_DRY_RUN attribute
>which allows requesting a dry run of a command. A dry run is simply
>a request to validate that a command would work, without performing any
>destructive changes.
>
>The attribute is supported by the devlink flash update as a way to
>validate an update, including potentially the binary image, without
>modifying the device.
>
>Add a "dry_run" option to the command line parsing which will enable
>this attribute when requested.
>
>To avoid potential issues, only allow the attribute to be added to
>commands when the kernel recognizes it. This is important because some
>commands do not perform strict validation. If we were to add the
>attribute without this check, an old kernel may silently accept the
>command and perform an update even when dry_run was requested.
>
>Before adding the attribute, check the maximum attribute from the
>CTRL_CMD_GETFAMILY and make sure that the kernel recognizes the
>DEVLINK_ATTR_DRY_RUN attribute.
>
>Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value
  2022-07-26  7:46   ` Jiri Pirko
@ 2022-08-26  0:40     ` Keller, Jacob E
  2022-08-26  8:38       ` Jiri Pirko
  0 siblings, 1 reply; 11+ messages in thread
From: Keller, Jacob E @ 2022-08-26  0:40 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nguyen, Anthony L,
	David Ahern, Stephen Hemminger, linux-doc



> -----Original Message-----
> From: Jiri Pirko <jiri@resnulli.us>
> Sent: Tuesday, July 26, 2022 12:47 AM
> To: Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: netdev@vger.kernel.org; Jonathan Corbet <corbet@lwn.net>; Jiri Pirko
> <jiri@nvidia.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> David Ahern <dsahern@kernel.org>; Stephen Hemminger
> <stephen@networkplumber.org>; linux-doc@vger.kernel.org
> Subject: Re: [iproute2-next v3 2/3] mnlg: add function to get
> CTRL_ATTR_MAXATTR value
> 
> Mon, Jul 25, 2022 at 10:56:49PM CEST, jacob.e.keller@intel.com wrote:
> >Add a new function to extract the CTRL_ATTR_MAXATTR attribute of the
> >CTRL_CMD_GETFAMILY request. This will be used to allow reading the
> >maximum supported devlink attribute of the running kernel in an upcoming
> >change.
> >
> >Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> 
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>

I had a new approach which just extracted maxattr and stored it hwnever we call CTRL_CMD_GETFAMILY, which I think is a preferable approach to this. That was part of the series I sent recently to support policy checking. I think I'd prefer that route now over this patch.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value
  2022-08-26  0:40     ` Keller, Jacob E
@ 2022-08-26  8:38       ` Jiri Pirko
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Pirko @ 2022-08-26  8:38 UTC (permalink / raw)
  To: Keller, Jacob E
  Cc: netdev, Jonathan Corbet, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nguyen, Anthony L,
	David Ahern, Stephen Hemminger, linux-doc

Fri, Aug 26, 2022 at 02:40:20AM CEST, jacob.e.keller@intel.com wrote:
>
>
>> -----Original Message-----
>> From: Jiri Pirko <jiri@resnulli.us>
>> Sent: Tuesday, July 26, 2022 12:47 AM
>> To: Keller, Jacob E <jacob.e.keller@intel.com>
>> Cc: netdev@vger.kernel.org; Jonathan Corbet <corbet@lwn.net>; Jiri Pirko
>> <jiri@nvidia.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet
>> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
>> <pabeni@redhat.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
>> David Ahern <dsahern@kernel.org>; Stephen Hemminger
>> <stephen@networkplumber.org>; linux-doc@vger.kernel.org
>> Subject: Re: [iproute2-next v3 2/3] mnlg: add function to get
>> CTRL_ATTR_MAXATTR value
>> 
>> Mon, Jul 25, 2022 at 10:56:49PM CEST, jacob.e.keller@intel.com wrote:
>> >Add a new function to extract the CTRL_ATTR_MAXATTR attribute of the
>> >CTRL_CMD_GETFAMILY request. This will be used to allow reading the
>> >maximum supported devlink attribute of the running kernel in an upcoming
>> >change.
>> >
>> >Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>> 
>> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
>
>I had a new approach which just extracted maxattr and stored it hwnever we call CTRL_CMD_GETFAMILY, which I think is a preferable approach to this. That was part of the series I sent recently to support policy checking. I think I'd prefer that route now over this patch.

Send it :)

>
>Thanks,
>Jake

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-08-26  8:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25 20:56 [iproute2-next v3 0/3] devlink: support dry run attribute for flash update Jacob Keller
2022-07-25 20:56 ` [iproute2-next v3 1/3] update <linux/devlink.h> UAPI header Jacob Keller
2022-07-25 20:56 ` [iproute2-next v3 2/3] mnlg: add function to get CTRL_ATTR_MAXATTR value Jacob Keller
2022-07-26  7:46   ` Jiri Pirko
2022-08-26  0:40     ` Keller, Jacob E
2022-08-26  8:38       ` Jiri Pirko
2022-07-25 20:56 ` [iproute2-next v3 3/3] devlink: add dry run attribute support to devlink flash Jacob Keller
2022-07-25 21:13   ` Stephen Hemminger
2022-07-25 21:19     ` Keller, Jacob E
2022-07-25 21:27     ` Keller, Jacob E
2022-07-26  7:47   ` Jiri Pirko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.