diff mbox

[1/1] validation: classification: fix TCP/UDP checksum update

Message ID 1473430749-19279-1-git-send-email-bala.manoharan@linaro.org
State New
Headers show

Commit Message

Balasubramanian Manoharan Sept. 9, 2016, 2:19 p.m. UTC
Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

---
 .../validation/api/classification/odp_classification_common.c  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
1.9.1

Comments

Balasubramanian Manoharan Sept. 19, 2016, 4:15 p.m. UTC | #1
Ping.

Regards,
Bala


On 9 September 2016 at 19:49, Balasubramanian Manoharan
<bala.manoharan@linaro.org> wrote:
> Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

>

> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

> ---

>  .../validation/api/classification/odp_classification_common.c  | 10 +++++++++-

>  1 file changed, 9 insertions(+), 1 deletion(-)

>

> diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c

> index 7a42ac7..93ac0c0 100644

> --- a/test/common_plat/validation/api/classification/odp_classification_common.c

> +++ b/test/common_plat/validation/api/classification/odp_classification_common.c

> @@ -11,6 +11,7 @@

>  #include <odp/helper/ip.h>

>  #include <odp/helper/udp.h>

>  #include <odp/helper/tcp.h>

> +#include "test_debug.h"

>

>  typedef struct cls_test_packet {

>         odp_u32be_t magic;

> @@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>         parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask);

>         ip->src_addr = odp_cpu_to_be_32(addr);

>         ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;

> +       odp_packet_has_ipv4_set(pkt, 1);

> +

>         if (flag_udp)

>                 ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +

>                                                ODPH_IPV4HDR_LEN);

> @@ -318,14 +321,19 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>                 udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>                 udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);

>                 udp->chksum = 0;

> +               odp_packet_has_udp_set(pkt, 1);

> +               if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

> +                       LOG_ERR("odph_udp_tcp_chksum failed\n");

>         } else {

>                 odp_packet_l4_offset_set(pkt, offset);

>                 tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);

>                 tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);

>                 tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>                 tcp->hl = ODPH_TCPHDR_LEN / 4;

> -               /* TODO: checksum field has to be updated */

>                 tcp->cksm = 0;

> +               odp_packet_has_tcp_set(pkt, 1);

> +               if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

> +                       LOG_ERR("odph_udp_tcp_chksum failed\n");

>         }

>

>         /* set pkt sequence number */

> --

> 1.9.1

>
Brian Brooks Sept. 22, 2016, 2:46 a.m. UTC | #2
On 09/09 19:49:09, Balasubramanian Manoharan wrote:
> Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

> 

> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

> ---

>  .../validation/api/classification/odp_classification_common.c  | 10 +++++++++-

>  1 file changed, 9 insertions(+), 1 deletion(-)

> 

> diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c

> index 7a42ac7..93ac0c0 100644

> --- a/test/common_plat/validation/api/classification/odp_classification_common.c

> +++ b/test/common_plat/validation/api/classification/odp_classification_common.c

> @@ -11,6 +11,7 @@

>  #include <odp/helper/ip.h>

>  #include <odp/helper/udp.h>

>  #include <odp/helper/tcp.h>

> +#include "test_debug.h"

>  

>  typedef struct cls_test_packet {

>  	odp_u32be_t magic;

> @@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>  	parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask);

>  	ip->src_addr = odp_cpu_to_be_32(addr);

>  	ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;

> +	odp_packet_has_ipv4_set(pkt, 1);

> +

>  	if (flag_udp)

>  		ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +

>  					       ODPH_IPV4HDR_LEN);

> @@ -318,14 +321,19 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>  		udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>  		udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);

>  		udp->chksum = 0;

> +		odp_packet_has_udp_set(pkt, 1);

> +		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

> +			LOG_ERR("odph_udp_tcp_chksum failed\n");

>  	} else {

>  		odp_packet_l4_offset_set(pkt, offset);

>  		tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);

>  		tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);

>  		tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>  		tcp->hl = ODPH_TCPHDR_LEN / 4;

> -		/* TODO: checksum field has to be updated */

>  		tcp->cksm = 0;

> +		odp_packet_has_tcp_set(pkt, 1);

> +		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

> +			LOG_ERR("odph_udp_tcp_chksum failed\n");


Should pkt be free'd here and return ODP_PACKET_INVALID, or will this be caught
later on in the test?

>  	}

>  

>  	/* set pkt sequence number */

> -- 

> 1.9.1

>
Balasubramanian Manoharan Sept. 22, 2016, 10:22 p.m. UTC | #3
Regards,
Bala


On 21 September 2016 at 19:46, Brian Brooks <brian.brooks@linaro.org> wrote:
> On 09/09 19:49:09, Balasubramanian Manoharan wrote:

>> Fixes https://bugs.linaro.org/show_bug.cgi?id=2512

>>

>> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

>> ---

>>  .../validation/api/classification/odp_classification_common.c  | 10 +++++++++-

>>  1 file changed, 9 insertions(+), 1 deletion(-)

>>

>> diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c

>> index 7a42ac7..93ac0c0 100644

>> --- a/test/common_plat/validation/api/classification/odp_classification_common.c

>> +++ b/test/common_plat/validation/api/classification/odp_classification_common.c

>> @@ -11,6 +11,7 @@

>>  #include <odp/helper/ip.h>

>>  #include <odp/helper/udp.h>

>>  #include <odp/helper/tcp.h>

>> +#include "test_debug.h"

>>

>>  typedef struct cls_test_packet {

>>       odp_u32be_t magic;

>> @@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>>       parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask);

>>       ip->src_addr = odp_cpu_to_be_32(addr);

>>       ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;

>> +     odp_packet_has_ipv4_set(pkt, 1);

>> +

>>       if (flag_udp)

>>               ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +

>>                                              ODPH_IPV4HDR_LEN);

>> @@ -318,14 +321,19 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,

>>               udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>>               udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);

>>               udp->chksum = 0;

>> +             odp_packet_has_udp_set(pkt, 1);

>> +             if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

>> +                     LOG_ERR("odph_udp_tcp_chksum failed\n");

>>       } else {

>>               odp_packet_l4_offset_set(pkt, offset);

>>               tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);

>>               tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);

>>               tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);

>>               tcp->hl = ODPH_TCPHDR_LEN / 4;

>> -             /* TODO: checksum field has to be updated */

>>               tcp->cksm = 0;

>> +             odp_packet_has_tcp_set(pkt, 1);

>> +             if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)

>> +                     LOG_ERR("odph_udp_tcp_chksum failed\n");

>

> Should pkt be free'd here and return ODP_PACKET_INVALID, or will this be caught

> later on in the test?


Yes. We have to free the packet and mark the test case as failure.
Will update the same in next version.

Regards,
Bala
>

>>       }

>>

>>       /* set pkt sequence number */

>> --

>> 1.9.1

>>
Maxim Uvarov Oct. 6, 2016, 12:33 p.m. UTC | #4
On 09/23/16 01:22, Bala Manoharan wrote:
> Yes. We have to free the packet and mark the test case as failure.

> Will update the same in next version.

>

> Regards,

> Bala


Needed v2 here.

Maxim.
diff mbox

Patch

diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c
index 7a42ac7..93ac0c0 100644
--- a/test/common_plat/validation/api/classification/odp_classification_common.c
+++ b/test/common_plat/validation/api/classification/odp_classification_common.c
@@ -11,6 +11,7 @@ 
 #include <odp/helper/ip.h>
 #include <odp/helper/udp.h>
 #include <odp/helper/tcp.h>
+#include "test_debug.h"
 
 typedef struct cls_test_packet {
 	odp_u32be_t magic;
@@ -291,6 +292,8 @@  odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
 	parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask);
 	ip->src_addr = odp_cpu_to_be_32(addr);
 	ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
+	odp_packet_has_ipv4_set(pkt, 1);
+
 	if (flag_udp)
 		ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len +
 					       ODPH_IPV4HDR_LEN);
@@ -318,14 +321,19 @@  odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
 		udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
 		udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN);
 		udp->chksum = 0;
+		odp_packet_has_udp_set(pkt, 1);
+		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)
+			LOG_ERR("odph_udp_tcp_chksum failed\n");
 	} else {
 		odp_packet_l4_offset_set(pkt, offset);
 		tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL);
 		tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT);
 		tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT);
 		tcp->hl = ODPH_TCPHDR_LEN / 4;
-		/* TODO: checksum field has to be updated */
 		tcp->cksm = 0;
+		odp_packet_has_tcp_set(pkt, 1);
+		if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0)
+			LOG_ERR("odph_udp_tcp_chksum failed\n");
 	}
 
 	/* set pkt sequence number */