[dpdk-dev] [PATCH v5 5/8] app/testpmd: do not change ip addrs in csum engine

Olivier Matz olivier.matz at 6wind.com
Fri Oct 7 18:05:15 CEST 2016


The csum forward engine was updated to change the IP addresses in the
packet data in
commit 51f694dd40f5 ("app/testpmd: rework checksum forward engine")

This was done to ensure that the checksum is correctly reprocessed when
using hardware checksum offload. But the functions
process_inner_cksums() and process_outer_cksums() already reset the
checksum field to 0, so this is not necessary.

Moreover, this makes the engine more complex than needed, and prevents
to easily use it to forward traffic (like iperf) as it modifies the
packets.

This patch drops this behavior.

Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
 app/test-pmd/csumonly.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index e7ee0b3..eeb67db 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -317,21 +317,6 @@ parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info)
 	info->l2_len = 0;
 }
 
-/* modify the IPv4 or IPv4 source address of a packet */
-static void
-change_ip_addresses(void *l3_hdr, uint16_t ethertype)
-{
-	struct ipv4_hdr *ipv4_hdr = l3_hdr;
-	struct ipv6_hdr *ipv6_hdr = l3_hdr;
-
-	if (ethertype == _htons(ETHER_TYPE_IPv4)) {
-		ipv4_hdr->src_addr =
-			rte_cpu_to_be_32(rte_be_to_cpu_32(ipv4_hdr->src_addr) + 1);
-	} else if (ethertype == _htons(ETHER_TYPE_IPv6)) {
-		ipv6_hdr->src_addr[15] = ipv6_hdr->src_addr[15] + 1;
-	}
-}
-
 /* if possible, calculate the checksum of a packet in hw or sw,
  * depending on the testpmd command line configuration */
 static uint64_t
@@ -608,7 +593,6 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  * Receive a burst of packets, and for each packet:
  *  - parse packet, and try to recognize a supported packet type (1)
  *  - if it's not a supported packet type, don't touch the packet, else:
- *  - modify the IPs in inner headers and in outer headers if any
  *  - reprocess the checksum of all supported layers. This is done in SW
  *    or HW, depending on testpmd command line configuration
  *  - if TSO is enabled in testpmd command line, also flag the mbuf for TCP
@@ -725,20 +709,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len;
 		}
 
-		/* step 2: change all source IPs (v4 or v6) so we need
-		 * to recompute the chksums even if they were correct */
-
-		change_ip_addresses(l3_hdr, info.ethertype);
-		if (info.is_tunnel == 1)
-			change_ip_addresses(outer_l3_hdr, info.outer_ethertype);
-
-		/* step 3: depending on user command line configuration,
+		/* step 2: depending on user command line configuration,
 		 * recompute checksum either in software or flag the
 		 * mbuf to offload the calculation to the NIC. If TSO
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		tx_ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info,
+			testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
@@ -748,7 +726,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				testpmd_ol_flags);
 		}
 
-		/* step 4: fill the mbuf meta data (flags and header lengths) */
+		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
 		if (info.is_tunnel == 1) {
 			if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) {
-- 
2.8.1



More information about the dev mailing list