]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Fix statistics bind/unbing argument handling
authorIdo Kalir <idok@nvidia.com>
Sun, 14 Feb 2021 08:33:35 +0000 (10:33 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 22 Feb 2021 18:52:39 +0000 (10:52 -0800)
The dump isn't supported for the statistics bind/unbind commands
because they operate on specific QP counters. This is different
from query commands that can operate on many objects at the same
time.

Let's check the user input and ensure that arguments are valid.

Fixes: a6d0773ebecc ("rdma: Add stat manual mode support")
Signed-off-by: Ido Kalir <idok@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
rdma/rdma.h
rdma/stat.c
rdma/utils.c

index fc8bcf09274d09ce466d01027abc6b160fc2c2a1..ab3b388f23f90c77b9de60e5aade6278e312bb25 100644 (file)
@@ -84,6 +84,7 @@ struct rd_cmd {
  * Parser interface
  */
 bool rd_no_arg(struct rd *rd);
+bool rd_is_multiarg(struct rd *rd);
 void rd_arg_inc(struct rd *rd);
 
 char *rd_argv(struct rd *rd);
index a2b5da1c7797f986ad0bc0cb13e9eb2f1bc2a16d..75d452885472b8f2118452e2dfa69abfae7d9ce2 100644 (file)
@@ -502,6 +502,12 @@ static int stat_get_arg(struct rd *rd, const char *arg)
                return -EINVAL;
 
        rd_arg_inc(rd);
+
+       if (rd_is_multiarg(rd)) {
+               pr_err("The parameter %s shouldn't include range\n", arg);
+               return -EINVAL;
+       }
+
        value = strtol(rd_argv(rd), &endp, 10);
        rd_arg_inc(rd);
 
@@ -523,6 +529,8 @@ static int stat_one_qp_bind(struct rd *rd)
                return ret;
 
        lqpn = stat_get_arg(rd, "lqpn");
+       if (lqpn < 0)
+               return lqpn;
 
        rd_prepare_msg(rd, RDMA_NLDEV_CMD_STAT_SET,
                       &seq, (NLM_F_REQUEST | NLM_F_ACK));
@@ -537,6 +545,9 @@ static int stat_one_qp_bind(struct rd *rd)
 
        if (rd_argc(rd)) {
                cntn = stat_get_arg(rd, "cntn");
+               if (cntn < 0)
+                       return cntn;
+
                mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_STAT_COUNTER_ID,
                                 cntn);
        }
@@ -607,13 +618,23 @@ static int stat_one_qp_unbind(struct rd *rd)
        unsigned int portid;
        uint32_t seq;
 
+       if (rd_no_arg(rd)) {
+               stat_help(rd);
+               return -EINVAL;
+       }
+
        ret = rd_build_filter(rd, stat_valid_filters);
        if (ret)
                return ret;
 
        cntn = stat_get_arg(rd, "cntn");
+       if (cntn < 0)
+               return cntn;
+
        if (rd_argc(rd)) {
                lqpn = stat_get_arg(rd, "lqpn");
+               if (lqpn < 0)
+                       return lqpn;
                return do_stat_qp_unbind_lqpn(rd, cntn, lqpn);
        }
 
index 2a201aa4aeb7fa86f78c368ab6ecc0e9a2f2be65..f84b102d2a5c5b9da2931cf6b24fb907c61ee0a4 100644 (file)
@@ -47,6 +47,13 @@ bool rd_no_arg(struct rd *rd)
        return rd_argc(rd) == 0;
 }
 
+bool rd_is_multiarg(struct rd *rd)
+{
+       if (!rd_argc(rd))
+               return false;
+       return strpbrk(rd_argv(rd), ",-") != NULL;
+}
+
 /*
  * Possible input:output
  * dev/port    | first port | is_dump_all