]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - rdma/utils.c
rdma: Make get_port_from_argv() returns valid port in strict port mode
[mirror_iproute2.git] / rdma / utils.c
index 9c885ad7389fa073deb1a09207bef613ff82ea93..95b669f39e307d0c0fb8e731ddb0e5eb92262cce 100644 (file)
@@ -56,7 +56,7 @@ bool rd_no_arg(struct rd *rd)
  * mlx5_1/1    | 1          | false
  * mlx5_1/-    | 0          | false
  *
- * In strict mode, /- will return error.
+ * In strict port mode, a non-0 port must be provided
  */
 static int get_port_from_argv(struct rd *rd, uint32_t *port,
                              bool *is_dump_all, bool strict_port)
@@ -64,7 +64,7 @@ static int get_port_from_argv(struct rd *rd, uint32_t *port,
        char *slash;
 
        *port = 0;
-       *is_dump_all = true;
+       *is_dump_all = strict_port ? false : true;
 
        slash = strchr(rd_argv(rd), '/');
        /* if no port found, return 0 */
@@ -83,6 +83,9 @@ static int get_port_from_argv(struct rd *rd, uint32_t *port,
                if (!*port && strlen(slash))
                        return -EINVAL;
        }
+       if (strict_port && (*port == 0))
+               return -EINVAL;
+
        return 0;
 }
 
@@ -445,6 +448,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
        [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE] = MNL_TYPE_U64,
        [RDMA_NLDEV_ATTR_STAT_MODE] = MNL_TYPE_U32,
        [RDMA_NLDEV_ATTR_STAT_RES] = MNL_TYPE_U32,
+       [RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK] = MNL_TYPE_U32,
 };
 
 int rd_attr_check(const struct nlattr *attr, int *typep)