diff mbox

test: l2fwd: do not use negativ array index

Message ID 1437062851-24624-1-git-send-email-maxim.uvarov@linaro.org
State Superseded
Headers show

Commit Message

Maxim Uvarov July 16, 2015, 4:07 p.m. UTC
odp_pktio_send() can return -1 error and that return code
can be used as array index in code bellow. On error just
increase drop counter and free packets.
https://bugs.linaro.org/show_bug.cgi?id=1688

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 example/packet/odp_pktio.c   | 1 +
 test/performance/odp_l2fwd.c | 1 +
 2 files changed, 2 insertions(+)

Comments

Bill Fischofer July 16, 2015, 4:11 p.m. UTC | #1
Typo in commit msg.  Should be negative, not negativ.

Other than that:

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>

On Thu, Jul 16, 2015 at 11:07 AM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:

> odp_pktio_send() can return -1 error and that return code
> can be used as array index in code bellow. On error just
> increase drop counter and free packets.
> https://bugs.linaro.org/show_bug.cgi?id=1688
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  example/packet/odp_pktio.c   | 1 +
>  test/performance/odp_l2fwd.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
> index 8004d69..040571b 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -291,6 +291,7 @@ static void *pktio_ifburst_thread(void *arg)
>                                 /* Swap Eth MACs and IP-addrs */
>                                 swap_pkt_addrs(pkt_tbl, pkts_ok);
>                                 sent = odp_pktio_send(pktio, pkt_tbl,
> pkts_ok);
> +                               sent = sent > 0 ? sent : 0;
>                                 if (odp_unlikely(sent < pkts_ok)) {
>                                         err_cnt += pkts_ok - sent;
>                                         do
> diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
> index 9cc201f..a408c7d 100644
> --- a/test/performance/odp_l2fwd.c
> +++ b/test/performance/odp_l2fwd.c
> @@ -231,6 +231,7 @@ static void *pktio_ifburst_thread(void *arg)
>                 if (pkts_ok > 0) {
>                         int sent = odp_pktio_send(pktio_dst, pkt_tbl,
> pkts_ok);
>
> +                       sent = sent > 0 ? sent : 0;
>                         if (odp_unlikely(sent < pkts_ok)) {
>                                 stats->drops += pkts_ok - sent;
>                                 do
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov July 16, 2015, 4:12 p.m. UTC | #2
On 07/16/15 19:11, Bill Fischofer wrote:
> Typo in commit msg.  Should be negative, not negativ.
>
> Other than that:
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>

thanks.  fixed that in v2 and remove l2fwd from topic because also fix 
in odp_pktio.c

Maxim.
>
> On Thu, Jul 16, 2015 at 11:07 AM, Maxim Uvarov 
> <maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     odp_pktio_send() can return -1 error and that return code
>     can be used as array index in code bellow. On error just
>     increase drop counter and free packets.
>     https://bugs.linaro.org/show_bug.cgi?id=1688
>
>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>     <mailto:maxim.uvarov@linaro.org>>
>     ---
>      example/packet/odp_pktio.c   | 1 +
>      test/performance/odp_l2fwd.c | 1 +
>      2 files changed, 2 insertions(+)
>
>     diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
>     index 8004d69..040571b 100644
>     --- a/example/packet/odp_pktio.c
>     +++ b/example/packet/odp_pktio.c
>     @@ -291,6 +291,7 @@ static void *pktio_ifburst_thread(void *arg)
>                                     /* Swap Eth MACs and IP-addrs */
>                                     swap_pkt_addrs(pkt_tbl, pkts_ok);
>                                     sent = odp_pktio_send(pktio,
>     pkt_tbl, pkts_ok);
>     +                               sent = sent > 0 ? sent : 0;
>                                     if (odp_unlikely(sent < pkts_ok)) {
>                                             err_cnt += pkts_ok - sent;
>                                             do
>     diff --git a/test/performance/odp_l2fwd.c
>     b/test/performance/odp_l2fwd.c
>     index 9cc201f..a408c7d 100644
>     --- a/test/performance/odp_l2fwd.c
>     +++ b/test/performance/odp_l2fwd.c
>     @@ -231,6 +231,7 @@ static void *pktio_ifburst_thread(void *arg)
>                     if (pkts_ok > 0) {
>                             int sent = odp_pktio_send(pktio_dst,
>     pkt_tbl, pkts_ok);
>
>     +                       sent = sent > 0 ? sent : 0;
>                             if (odp_unlikely(sent < pkts_ok)) {
>                                     stats->drops += pkts_ok - sent;
>                                     do
>     --
>     1.9.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
diff mbox

Patch

diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 8004d69..040571b 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -291,6 +291,7 @@  static void *pktio_ifburst_thread(void *arg)
 				/* Swap Eth MACs and IP-addrs */
 				swap_pkt_addrs(pkt_tbl, pkts_ok);
 				sent = odp_pktio_send(pktio, pkt_tbl, pkts_ok);
+				sent = sent > 0 ? sent : 0;
 				if (odp_unlikely(sent < pkts_ok)) {
 					err_cnt += pkts_ok - sent;
 					do
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 9cc201f..a408c7d 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -231,6 +231,7 @@  static void *pktio_ifburst_thread(void *arg)
 		if (pkts_ok > 0) {
 			int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
 
+			sent = sent > 0 ? sent : 0;
 			if (odp_unlikely(sent < pkts_ok)) {
 				stats->drops += pkts_ok - sent;
 				do