diff mbox

[v2] validation: classification: fix incorrect ipv4 checksum update

Message ID 1424667031-11687-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 4d53c49156030736f11271a6baed92bf55d6fe0f
Headers show

Commit Message

Balasubramanian Manoharan Feb. 23, 2015, 4:50 a.m. UTC
From: Balasubramanian Manoharan <bala.manoharan@linaro.org>

Fixes an issue where ipv4 checksum field was not updated after modifying the src
addr of the packet.

https://bugs.linaro.org/show_bug.cgi?id=1231

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
v2: updates review comments from Mike

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

Comments

Mike Holmes Feb. 23, 2015, 5:31 p.m. UTC | #1
On 22 February 2015 at 23:50, <bala.manoharan@linaro.org> wrote:

> From: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>
> Fixes an issue where ipv4 checksum field was not updated after modifying
> the src
> addr of the packet.
>
> https://bugs.linaro.org/show_bug.cgi?id=1231
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>

Reviewed-by: Mike Holmes <mike.holmes@linaro.org>


> ---
> v2: updates review comments from Mike
>
>  test/validation/classification/odp_classification_tests.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/test/validation/classification/odp_classification_tests.c
> b/test/validation/classification/odp_classification_tests.c
> index 564455c..3688dd0 100644
> --- a/test/validation/classification/odp_classification_tests.c
> +++ b/test/validation/classification/odp_classification_tests.c
> @@ -221,7 +221,7 @@ odp_packet_t create_packet(bool vlan)
>         seqno = odp_atomic_fetch_inc_u32(&seq);
>         ip->id = odp_cpu_to_be_16(seqno);
>         ip->chksum = 0;
> -       odph_ipv4_csum_update(pkt);
> +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>         offset += ODPH_IPV4HDR_LEN;
>
>         /* udp */
> @@ -404,6 +404,9 @@ void test_cls_pmr_chain(void)
>         ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>         parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
>         ip->src_addr = odp_cpu_to_be_32(addr);
> +       ip->chksum = 0;
> +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
> +
>         udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
>         udp->src_port = odp_cpu_to_be_16(CLS_PMR_CHAIN_SPORT);
>
> @@ -419,6 +422,8 @@ void test_cls_pmr_chain(void)
>         ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>         parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
>         ip->src_addr = odp_cpu_to_be_32(addr);
> +       ip->chksum = 0;
> +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>
>         enqueue_loop_interface(pkt);
>         pkt = receive_packet(&queue, ODP_TIME_SEC);
> @@ -729,6 +734,9 @@ void test_pktio_pmr_match_set_cos(void)
>         ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>         parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask);
>         ip->src_addr = odp_cpu_to_be_32(addr);
> +       ip->chksum = 0;
> +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
> +
>         udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
>         udp->src_port = odp_cpu_to_be_16(CLS_PMR_SET_SPORT);
>         enqueue_loop_interface(pkt);
> --
> 2.0.1.472.g6f92e5f
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Feb. 24, 2015, 2:55 p.m. UTC | #2
Merged!

Maxim.

On 02/23/2015 08:31 PM, Mike Holmes wrote:
>
>
> On 22 February 2015 at 23:50, <bala.manoharan@linaro.org 
> <mailto:bala.manoharan@linaro.org>> wrote:
>
>     From: Balasubramanian Manoharan <bala.manoharan@linaro.org
>     <mailto:bala.manoharan@linaro.org>>
>
>     Fixes an issue where ipv4 checksum field was not updated after
>     modifying the src
>     addr of the packet.
>
>     https://bugs.linaro.org/show_bug.cgi?id=1231
>
>     Signed-off-by: Balasubramanian Manoharan
>     <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>>
>
>
> Reviewed-by: Mike Holmes <mike.holmes@linaro.org 
> <mailto:mike.holmes@linaro.org>>
>
>     ---
>     v2: updates review comments from Mike
>
>      test/validation/classification/odp_classification_tests.c | 10
>     +++++++++-
>      1 file changed, 9 insertions(+), 1 deletion(-)
>
>     diff --git
>     a/test/validation/classification/odp_classification_tests.c
>     b/test/validation/classification/odp_classification_tests.c
>     index 564455c..3688dd0 100644
>     --- a/test/validation/classification/odp_classification_tests.c
>     +++ b/test/validation/classification/odp_classification_tests.c
>     @@ -221,7 +221,7 @@ odp_packet_t create_packet(bool vlan)
>             seqno = odp_atomic_fetch_inc_u32(&seq);
>             ip->id = odp_cpu_to_be_16(seqno);
>             ip->chksum = 0;
>     -       odph_ipv4_csum_update(pkt);
>     +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>             offset += ODPH_IPV4HDR_LEN;
>
>             /* udp */
>     @@ -404,6 +404,9 @@ void test_cls_pmr_chain(void)
>             ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>             parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
>             ip->src_addr = odp_cpu_to_be_32(addr);
>     +       ip->chksum = 0;
>     +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>     +
>             udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
>             udp->src_port = odp_cpu_to_be_16(CLS_PMR_CHAIN_SPORT);
>
>     @@ -419,6 +422,8 @@ void test_cls_pmr_chain(void)
>             ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>             parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
>             ip->src_addr = odp_cpu_to_be_32(addr);
>     +       ip->chksum = 0;
>     +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>
>             enqueue_loop_interface(pkt);
>             pkt = receive_packet(&queue, ODP_TIME_SEC);
>     @@ -729,6 +734,9 @@ void test_pktio_pmr_match_set_cos(void)
>             ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
>             parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask);
>             ip->src_addr = odp_cpu_to_be_32(addr);
>     +       ip->chksum = 0;
>     +       ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
>     +
>             udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
>             udp->src_port = odp_cpu_to_be_16(CLS_PMR_SET_SPORT);
>             enqueue_loop_interface(pkt);
>     --
>     2.0.1.472.g6f92e5f
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index 564455c..3688dd0 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -221,7 +221,7 @@  odp_packet_t create_packet(bool vlan)
 	seqno = odp_atomic_fetch_inc_u32(&seq);
 	ip->id = odp_cpu_to_be_16(seqno);
 	ip->chksum = 0;
-	odph_ipv4_csum_update(pkt);
+	ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
 	offset += ODPH_IPV4HDR_LEN;
 
 	/* udp */
@@ -404,6 +404,9 @@  void test_cls_pmr_chain(void)
 	ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 	parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
 	ip->src_addr = odp_cpu_to_be_32(addr);
+	ip->chksum = 0;
+	ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
+
 	udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
 	udp->src_port = odp_cpu_to_be_16(CLS_PMR_CHAIN_SPORT);
 
@@ -419,6 +422,8 @@  void test_cls_pmr_chain(void)
 	ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 	parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
 	ip->src_addr = odp_cpu_to_be_32(addr);
+	ip->chksum = 0;
+	ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
 
 	enqueue_loop_interface(pkt);
 	pkt = receive_packet(&queue, ODP_TIME_SEC);
@@ -729,6 +734,9 @@  void test_pktio_pmr_match_set_cos(void)
 	ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 	parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask);
 	ip->src_addr = odp_cpu_to_be_32(addr);
+	ip->chksum = 0;
+	ip->chksum = odp_cpu_to_be_16(odph_ipv4_csum_update(pkt));
+
 	udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
 	udp->src_port = odp_cpu_to_be_16(CLS_PMR_SET_SPORT);
 	enqueue_loop_interface(pkt);