diff mbox

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

Message ID 1423812716-3148-1-git-send-email-bala.manoharan@linaro.org
State Superseded
Headers show

Commit Message

Balasubramanian Manoharan Feb. 13, 2015, 7:31 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.

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 test/validation/classification/odp_classification_tests.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index 45822d3..a47ad1f 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 */
@@ -403,6 +403,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);
 
@@ -418,6 +421,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);
@@ -728,6 +733,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);