rdma: Fix statistics bind/unbing argument handling
Subsystems (3)
PATCH 1/1 rdma: Fix statistics bind/unbing argument handling
From: Ido Kalir <[email protected]>
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.
--- rdma/rdma.h | 1 + rdma/stat.c | 21 +++++++++++++++++++++ rdma/utils.c | 7 +++++++ 3 files changed, 29 insertions(+)
rdma/rdma.h +1 -0
@@ -83,6 +83,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);
rdma/stat.c +21 -0
@@ -455,6 +455,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);
@@ -476,6 +482,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 ));
@@ -490,6 +498,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); }
@@ -560,13 +571,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); }
rdma/utils.c +7 -0
@@ -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
--
2.29.2
what does iproute2-rc mean?
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
vs -next repo:
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/
How do you want me to mark the patches?
https://git.kernel.org/pub/scm/network/iproute2/
Thanks
Quoted 5 lines · Leon Romanovsky
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
so you are asking them to be committed for the 5.11 release?
Quoted 9 lines
vs -next repo:
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/How do you want me to mark the patches?
https://git.kernel.org/pub/scm/network/iproute2/
Thanks
Quoted 8 lines · David Ahern
Quoted 5 lines · Leon Romanovsky
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/so you are asking them to be committed for the 5.11 release?
This is a Fix to an existing issue (not theoretical one), so I was under impression that it should go to -rc repo and not to -next.
Personally, I don't care to which repo will this fix be applied as long as it is applied to one of the two iproute2 official repos.
Do you have clear guidance when should I send patches to iproute2-rc/iproute2-next?
Thanks
Quoted 5 lines · Leon Romanovsky
Quoted 4 lines · David Ahern
Quoted 3 lines · Leon Romanovsky
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/so you are asking them to be committed for the 5.11 release?
This is a Fix to an existing issue (not theoretical one), so I was under impression that it should go to -rc repo and not to -next.
It is assigned to Stephen for iproute2.
Quoted 6 lines
Personally, I don't care to which repo will this fix be applied as long as it is applied to one of the two iproute2 official repos.
Do you have clear guidance when should I send patches to iproute2-rc/iproute2-next?
It's the rc label that needs to be dropped: iproute2 or iproute2-next. Just like there is net and net-next.
Quoted 17 lines · David Ahern
Quoted 5 lines · Leon Romanovsky
Quoted 4 lines · David Ahern
Quoted 3 lines · Leon Romanovsky
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/so you are asking them to be committed for the 5.11 release?
This is a Fix to an existing issue (not theoretical one), so I was under impression that it should go to -rc repo and not to -next.
It is assigned to Stephen for iproute2.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Personally, I don't care to which repo will this fix be applied as long as it is applied to one of the two iproute2 official repos.
Do you have clear guidance when should I send patches to iproute2-rc/iproute2-next?
It's the rc label that needs to be dropped: iproute2 or iproute2-next.
Sure, no problem.
Thanks
Stephen Hemminger
AppliedQuoted 21 lines · On Thu, 18 Feb 2021 10:44:16 +0200 Leon Romanovsky <[email protected]> wrote:
Quoted 20 lines · David Ahern
Quoted 5 lines · Leon Romanovsky
Quoted 4 lines · David Ahern
Quoted 3 lines · Leon Romanovsky
Quoted 1 line · David Ahern
what does iproute2-rc mean?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Patch target is iproute2.git:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/so you are asking them to be committed for the 5.11 release?
This is a Fix to an existing issue (not theoretical one), so I was under impression that it should go to -rc repo and not to -next.
It is assigned to Stephen for iproute2.
Quoted 4 lines
Personally, I don't care to which repo will this fix be applied as long as it is applied to one of the two iproute2 official repos.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do you have clear guidance when should I send patches to iproute2-rc/iproute2-next?
It's the rc label that needs to be dropped: iproute2 or iproute2-next.
Sure, no problem.
Thanks
Applied, and fixed a minor whitespace issue reported by checkpatch