* [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
@ 2018-12-04 5:51 Wei Zhao
2018-12-04 7:46 ` Zhao1, Wei
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wei Zhao @ 2018-12-04 5:51 UTC (permalink / raw)
To: dev; +Cc: stable, yuan.peng, Wei Zhao
There is need to add boundary for input number from commandline,
If it beyond the defination, code will return error.
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 23ea7cc..515f95c 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token *token,
}
buf = (uint8_t *)ctx->object + arg->offset;
size = arg->size;
+ switch (size) {
+ case sizeof(uint8_t):
+ if (u > 0xff)
+ return -1;
+ case sizeof(uint16_t):
+ if (u > 0xffff)
+ return -1;
+ case sizeof(uint8_t [3]):
+ if (u > 0xffffff)
+ return -1;
+ case sizeof(uint32_t):
+ if (u > 0xffffffff)
+ return -1;
+ case sizeof(uint64_t):
+ if (u > 0xffffffffffffffff)
+ return -1;
+ default:
+ break;
+ }
objmask:
switch (size) {
case sizeof(uint8_t):
--
2.7.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
2018-12-04 5:51 [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Wei Zhao
@ 2018-12-04 7:46 ` Zhao1, Wei
2018-12-04 9:22 ` Ananyev, Konstantin
2018-12-06 2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
2 siblings, 0 replies; 6+ messages in thread
From: Zhao1, Wei @ 2018-12-04 7:46 UTC (permalink / raw)
To: dev; +Cc: stable, Peng, Yuan
Send on behalf of Peng, Yuan <yuan.peng@intel.com>
Tested-by: Peng, Yuan <yuan.peng@intel.com>
- Tested Branch: dpdk-master
- Tested commit 0da7f445df445630c794897347ee360d6fe6348b
- OS: 4.5.5-300.fc24.x86_64
- GCC: gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
- CPU: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
- NIC: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection [8086:10fb] (rev 01)
- Default x86_64-native-linuxapp-gcc configuration
- Prerequisites:
- Total 1 cases, 1 passed, 0 failed
- Prerequisites command / instruction:
Bind DUT ports to dpdk driver
- Case:
Steps:
Start test application with normal eal parameter.
./$RTE_TARGET/app/testpmd -c f -n 4 -- -i
testpmd> flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / udp src is 22 dst is 65536 / end actions queue index 0 / end
Bad arguments
testpmd> flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / udp src is 65536 dst is 33 / end actions queue index 0 / end
Bad arguments
the rule failed to be created.
I tried TCP/SCTP rule, and got the same result.
I tried validating the rule instead of creating the rules with wrong sport/dport, and got the same result.
The bug is fixed.
> -----Original Message-----
> From: Zhao1, Wei
> Sent: Tuesday, December 4, 2018 1:52 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Peng, Yuan <yuan.peng@intel.com>; Zhao1, Wei
> <wei.zhao1@intel.com>
> Subject: [PATCH] app/testpmd: add boundary check in flow commandline
>
> There is need to add boundary for input number from commandline, If it
> beyond the defination, code will return error.
>
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> ---
> app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 23ea7cc..515f95c 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token
> *token,
> }
> buf = (uint8_t *)ctx->object + arg->offset;
> size = arg->size;
> + switch (size) {
> + case sizeof(uint8_t):
> + if (u > 0xff)
> + return -1;
> + case sizeof(uint16_t):
> + if (u > 0xffff)
> + return -1;
> + case sizeof(uint8_t [3]):
> + if (u > 0xffffff)
> + return -1;
> + case sizeof(uint32_t):
> + if (u > 0xffffffff)
> + return -1;
> + case sizeof(uint64_t):
> + if (u > 0xffffffffffffffff)
> + return -1;
> + default:
> + break;
> + }
> objmask:
> switch (size) {
> case sizeof(uint8_t):
> --
> 2.7.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
2018-12-04 5:51 [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Wei Zhao
2018-12-04 7:46 ` Zhao1, Wei
@ 2018-12-04 9:22 ` Ananyev, Konstantin
2018-12-06 2:34 ` Zhao1, Wei
2018-12-06 2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
2 siblings, 1 reply; 6+ messages in thread
From: Ananyev, Konstantin @ 2018-12-04 9:22 UTC (permalink / raw)
To: Zhao1, Wei, dev; +Cc: stable, Peng, Yuan, Zhao1, Wei
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao
> Sent: Tuesday, December 4, 2018 5:52 AM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Peng, Yuan <yuan.peng@intel.com>; Zhao1, Wei <wei.zhao1@intel.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
>
> There is need to add boundary for input number from commandline,
> If it beyond the defination, code will return error.
>
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> ---
> app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 23ea7cc..515f95c 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token *token,
> }
> buf = (uint8_t *)ctx->object + arg->offset;
> size = arg->size;
> + switch (size) {
> + case sizeof(uint8_t):
> + if (u > 0xff)
> + return -1;
> + case sizeof(uint16_t):
> + if (u > 0xffff)
> + return -1;
> + case sizeof(uint8_t [3]):
> + if (u > 0xffffff)
> + return -1;
> + case sizeof(uint32_t):
> + if (u > 0xffffffff)
> + return -1;
> + case sizeof(uint64_t):
> + if (u > 0xffffffffffffffff)
> + return -1;
> + default:
> + break;
> + }
Why just not something like:
if (u > RTE_LEN2MASK(size * CHAR_BIT))
return -1;
?
Konstantin
> objmask:
> switch (size) {
> case sizeof(uint8_t):
> --
> 2.7.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
2018-12-04 9:22 ` Ananyev, Konstantin
@ 2018-12-06 2:34 ` Zhao1, Wei
0 siblings, 0 replies; 6+ messages in thread
From: Zhao1, Wei @ 2018-12-06 2:34 UTC (permalink / raw)
To: Ananyev, Konstantin, dev; +Cc: stable, Peng, Yuan
> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Tuesday, December 4, 2018 5:22 PM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org; Peng, Yuan <yuan.peng@intel.com>; Zhao1, Wei
> <wei.zhao1@intel.com>
> Subject: RE: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow
> commandline
>
>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao
> > Sent: Tuesday, December 4, 2018 5:52 AM
> > To: dev@dpdk.org
> > Cc: stable@dpdk.org; Peng, Yuan <yuan.peng@intel.com>; Zhao1, Wei
> > <wei.zhao1@intel.com>
> > Subject: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow
> > commandline
> >
> > There is need to add boundary for input number from commandline, If it
> > beyond the defination, code will return error.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > ---
> > app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index 23ea7cc..515f95c 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token
> *token,
> > }
> > buf = (uint8_t *)ctx->object + arg->offset;
> > size = arg->size;
> > + switch (size) {
> > + case sizeof(uint8_t):
> > + if (u > 0xff)
> > + return -1;
> > + case sizeof(uint16_t):
> > + if (u > 0xffff)
> > + return -1;
> > + case sizeof(uint8_t [3]):
> > + if (u > 0xffffff)
> > + return -1;
> > + case sizeof(uint32_t):
> > + if (u > 0xffffffff)
> > + return -1;
> > + case sizeof(uint64_t):
> > + if (u > 0xffffffffffffffff)
> > + return -1;
> > + default:
> > + break;
> > + }
>
> Why just not something like:
> if (u > RTE_LEN2MASK(size * CHAR_BIT))
> return -1;
> ?
> Konstantin
Ok, I will commit v2.
>
> > objmask:
> > switch (size) {
> > case sizeof(uint8_t):
> > --
> > 2.7.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] app/testpmd: add boundary check in flow commandline
2018-12-04 5:51 [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Wei Zhao
2018-12-04 7:46 ` Zhao1, Wei
2018-12-04 9:22 ` Ananyev, Konstantin
@ 2018-12-06 2:38 ` Wei Zhao
2018-12-21 15:05 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2 siblings, 1 reply; 6+ messages in thread
From: Wei Zhao @ 2018-12-06 2:38 UTC (permalink / raw)
To: dev; +Cc: stable, yuan.peng, konstantin.ananyev, Wei Zhao
There is need to add boundary for input number from commandline,
If it beyond the defination, code will return error.
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
v2:
change mask writing format.
---
app/test-pmd/cmdline_flow.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 23ea7cc..8b7a5c0 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4325,6 +4325,8 @@ parse_int(struct context *ctx, const struct token *token,
}
buf = (uint8_t *)ctx->object + arg->offset;
size = arg->size;
+ if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
+ return -1;
objmask:
switch (size) {
case sizeof(uint8_t):
--
2.7.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH v2] app/testpmd: add boundary check in flow commandline
2018-12-06 2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
@ 2018-12-21 15:05 ` Ferruh Yigit
0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2018-12-21 15:05 UTC (permalink / raw)
To: Wei Zhao, dev; +Cc: stable, yuan.peng, konstantin.ananyev
On 12/6/2018 2:38 AM, Wei Zhao wrote:
> There is need to add boundary for input number from commandline,
> If it beyond the defination, code will return error.
>
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-21 15:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 5:51 [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Wei Zhao
2018-12-04 7:46 ` Zhao1, Wei
2018-12-04 9:22 ` Ananyev, Konstantin
2018-12-06 2:34 ` Zhao1, Wei
2018-12-06 2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
2018-12-21 15:05 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).