@@ -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)
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] Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- devlink/devlink.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)