]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - devlink/devlink.c
devlink: update include files
[mirror_iproute2.git] / devlink / devlink.c
index bd48a73bc0e453fa617c23b5a5d3b1762d634351..ce2e46766617cd2fc62b7160c47af4d54d9624cc 100644 (file)
 #include <limits.h>
 #include <errno.h>
 #include <inttypes.h>
+#include <signal.h>
+#include <time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #include <sys/sysinfo.h>
 #define _LINUX_SYSINFO_H /* avoid collision with musl header */
 #include <linux/genetlink.h>
 #include <linux/devlink.h>
+#include <linux/netlink.h>
 #include <libmnl/libmnl.h>
 #include <netinet/ether.h>
+#include <sys/select.h>
+#include <sys/socket.h>
 #include <sys/types.h>
 
 #include "SNAPSHOT.h"
 #include "list.h"
 #include "mnlg.h"
-#include "json_writer.h"
+#include "json_print.h"
 #include "utils.h"
 #include "namespace.h"
 
@@ -6476,6 +6483,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 +6508,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)