On 5/21/19 8:22 AM, Parav Pandit wrote:
> diff --git a/rdma/sys.c b/rdma/sys.c
> new file mode 100644
> index 00000000..78e5198f
> --- /dev/null
> +++ b/rdma/sys.c
> @@ -0,0 +1,143 @@
> +/*
> + * sys.c     RDMA tool
> + *
> + *              This program is free software; you can redistribute it and/or
> + *              modify it under the terms of the GNU General Public License
> + *              as published by the Free Software Foundation; either version
> + *              2 of the License, or (at your option) any later version.
> + */

Please use the SPDX line like the other rdma files.

> +
> +#include "rdma.h"
> +
> +static int sys_help(struct rd *rd)
> +{
> +     pr_out("Usage: %s system show [ netns ]\n", rd->filename);
> +     pr_out("       %s system set netns { shared | exclusive }\n", 
> rd->filename);
> +     return 0;
> +}
> +
> +static const char *netns_modes_str[] = {
> +     "exclusive",
> +     "shared",
> +};
> +
> +static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
> +{
> +     struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
> +     struct rd *rd = data;
> +
> +     mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
> +
> +     if (tb[RDMA_NLDEV_SYS_ATTR_NETNS_MODE]) {
> +             const char *mode_str;
> +             uint8_t netns_mode;
> +
> +             netns_mode =
> +                     mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_NETNS_MODE]);
> +
> +             if (netns_mode <= ARRAY_SIZE(netns_modes_str))
> +                     mode_str = netns_modes_str[netns_mode];
> +             else
> +                     mode_str = "unknown";
> +
> +             if (rd->json_output)
> +                     jsonw_string_field(rd->jw, "netns", mode_str);
> +             else
> +                     pr_out("netns %s\n", mode_str);
> +     }
> +     return MNL_CB_OK;
> +}
> +
> +static int sys_show_no_args(struct rd *rd)
> +{
> +     uint32_t seq;
> +     int ret;
> +
> +     rd_prepare_msg(rd, RDMA_NLDEV_CMD_SYS_GET,
> +                    &seq, (NLM_F_REQUEST | NLM_F_ACK));
> +     ret = rd_send_msg(rd);
> +     if (ret)
> +             return ret;
> +
> +     ret = rd_recv_msg(rd, sys_show_parse_cb, rd, seq);
> +     return ret;

since you are fixing the header, why not just
        return rd_recv_msg(rd, sys_show_parse_cb, rd, seq);

like the other functions?

Reply via email to