From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net, jiri@resnulli.us
Cc: netdev@vger.kernel.org, kernel-team@fb.com,
jacob.e.keller@intel.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH iproute2-next v3] devlink: support kernel-side snapshot id allocation
Date: Thu, 30 Apr 2020 10:57:59 -0700 [thread overview]
Message-ID: <20200430175759.1301789-5-kuba@kernel.org> (raw)
In-Reply-To: <20200430175759.1301789-1-kuba@kernel.org>
Make ID argument optional and read the snapshot info
that kernel sends us.
$ devlink region new netdevsim/netdevsim1/dummy
netdevsim/netdevsim1/dummy: snapshot 0
$ devlink -jp region new netdevsim/netdevsim1/dummy
{
"regions": {
"netdevsim/netdevsim1/dummy": {
"snapshot": [ 1 ]
}
}
}
$ devlink region show netdevsim/netdevsim1/dummy
netdevsim/netdevsim1/dummy: size 32768 snapshot [0 1]
v3: back to v1..
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
devlink/devlink.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index bd48a73bc0e4..507972c360a7 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6476,6 +6476,23 @@ static int cmd_region_read(struct dl *dl)
return err;
}
+static int cmd_region_snapshot_new_cb(const struct nlmsghdr *nlh, void *data)
+{
+ struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+ struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+ struct dl *dl = data;
+
+ mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+ if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
+ !tb[DEVLINK_ATTR_REGION_NAME] ||
+ !tb[DEVLINK_ATTR_REGION_SNAPSHOT_ID])
+ return MNL_CB_ERROR;
+
+ pr_out_region(dl, tb);
+
+ return MNL_CB_OK;
+}
+
static int cmd_region_snapshot_new(struct dl *dl)
{
struct nlmsghdr *nlh;
@@ -6484,12 +6501,15 @@ static int cmd_region_snapshot_new(struct dl *dl)
nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_NEW,
NLM_F_REQUEST | NLM_F_ACK);
- err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
- DL_OPT_REGION_SNAPSHOT_ID, 0);
+ err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION,
+ DL_OPT_REGION_SNAPSHOT_ID);
if (err)
return err;
- return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
+ pr_out_section_start(dl, "regions");
+ err = _mnlg_socket_sndrcv(dl->nlg, nlh, cmd_region_snapshot_new_cb, dl);
+ pr_out_section_end(dl);
+ return err;
}
static void cmd_region_help(void)
--
2.25.4
next prev parent reply other threads:[~2020-04-30 17:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 17:57 [PATCH net-next v3 0/3] devlink: kernel region snapshot id allocation Jakub Kicinski
2020-04-30 17:57 ` [PATCH net-next v3 1/3] devlink: factor out building a snapshot notification Jakub Kicinski
2020-05-01 8:51 ` Jiri Pirko
2020-05-01 21:27 ` Jacob Keller
2020-04-30 17:57 ` [PATCH net-next v3 2/3] devlink: let kernel allocate region snapshot id Jakub Kicinski
2020-05-01 8:59 ` Jiri Pirko
2020-05-01 21:32 ` Jacob Keller
2020-04-30 17:57 ` [PATCH net-next v3 3/3] docs: devlink: clarify the scope of " Jakub Kicinski
2020-05-01 8:59 ` Jiri Pirko
2020-05-01 21:34 ` Jacob Keller
2020-04-30 17:57 ` Jakub Kicinski [this message]
2020-05-02 5:58 ` [PATCH iproute2-next v3] devlink: support kernel-side snapshot id allocation Jiri Pirko
2020-05-05 16:14 ` David Ahern
2020-05-05 16:20 ` Jakub Kicinski
2020-05-05 16:59 ` David Ahern
2020-05-05 17:04 ` [PATCH iproute2-next RESEND] " Jakub Kicinski
2020-05-05 17:11 ` David Ahern
2020-05-05 17:05 ` [PATCH iproute2-next v3] " Jakub Kicinski
2020-05-05 17:06 ` Jakub Kicinski
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=20200430175759.1301789-5-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=jacob.e.keller@intel.com \
--cc=jiri@resnulli.us \
--cc=kernel-team@fb.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).