From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 003EE5A4B for ; Fri, 22 May 2015 19:03:26 +0200 (CEST) Received: by wgez8 with SMTP id z8so23576892wge.0 for ; Fri, 22 May 2015 10:03:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=G7QUAsM6UiuYRL7IPMRK3RdgfmWAafW/6IUoWcJOwHg=; b=Rzkh1pMYyk7mCFHkoSiUo1f2QWBoDPPELJOzrsJddM6M8xFpz+cWa+QLlC8MosNqPd 5ET+0tLLVupOeeH/dSllKA6agfOCrXwTVTNNn7U0Iyjz1SV2I5BVrctOII5RC86/havQ 286QhmEwJT8ak+VGh3SG50OanqzkHONwsy0oB2kwApO8z3SCidhlGKqkmzs/t+B158lB tkDdhiEpQoknqr/e/ixiVPsOABNrxfIjQQL02gQkDmXwjMSWQ5iuie2XOPJEBQpcstu1 aoUmGeY61lxQmt/p155JSgB+b+ISl8HAEkMgKbF949QgkmU+6JoJpxEmgr0bWKWbXMbq nqeg== X-Gm-Message-State: ALoCoQnPPaupZfdqplyT/Nn+1RoIbV6jKw0opKinVbObM1F/9jdrRpcM9xAnMsgCsDfc/mmEt2No X-Received: by 10.180.88.99 with SMTP id bf3mr9326193wib.75.1432314206828; Fri, 22 May 2015 10:03:26 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id f6sm3978033wjq.31.2015.05.22.10.03.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 May 2015 10:03:25 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 22 May 2015 19:03:12 +0200 Message-Id: <1432314192-17828-1-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432292852-15701-2-git-send-email-adrien.mazarguil@6wind.com> References: <1432292852-15701-2-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v2] app/testpmd: compute checksum in icmpecho replies X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2015 17:03:27 -0000 ICMP echo replies with invalid checksums may be dropped by network nodes or ignored by the ping utility. Signed-off-by: Adrien Mazarguil Acked-by: Ivan Boule --- v2: - Compute correct checksum value by taking overflow into account. app/test-pmd/icmpecho.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index c5933f4..e249e71 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -295,6 +295,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) uint16_t vlan_id; uint16_t arp_op; uint16_t arp_pro; + uint32_t cksum; uint8_t i; int l2_len; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES @@ -445,7 +446,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) * - switch IPv4 source and destinations addresses, * - set IP_ICMP_ECHO_REPLY in ICMP header. * No need to re-compute the IP header checksum. - * Reset ICMP checksum. + * ICMP checksum is computed by assuming it is valid in the + * echo request and not verified. */ ether_addr_copy(ð_h->s_addr, ð_addr); ether_addr_copy(ð_h->d_addr, ð_h->s_addr); @@ -454,7 +456,12 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) ip_h->src_addr = ip_h->dst_addr; ip_h->dst_addr = ip_addr; icmp_h->icmp_type = IP_ICMP_ECHO_REPLY; - icmp_h->icmp_cksum = 0; + cksum = ~icmp_h->icmp_cksum & 0xffff; + cksum += ~htons(IP_ICMP_ECHO_REQUEST << 8) & 0xffff; + cksum += htons(IP_ICMP_ECHO_REPLY << 8); + cksum = (cksum & 0xffff) + (cksum >> 16); + cksum = (cksum & 0xffff) + (cksum >> 16); + icmp_h->icmp_cksum = ~cksum; pkts_burst[nb_replies++] = pkt; } -- 2.1.0