From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by dpdk.org (Postfix) with ESMTP id 3059AA2F for ; Sat, 9 Apr 2016 15:45:20 +0200 (CEST) Received: by mail-lf0-f47.google.com with SMTP id j11so107291988lfb.1 for ; Sat, 09 Apr 2016 06:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=9sAxqiey4hf1CXuyus/IItVeoeJbAL3YKzXoYMrVj+A=; b=E+YrcM4+6O8SliayRNgR63OB8ItCbEc1xEvMAU3uh/X5gVXxM55oE1kR/exricZbSL hnGSKs9in2i5ne7jxwjA0TfqyIxjcVXYbgKXYGKMrb8ei8w1YDBlw2Y2EzyqNNbcufeD gsHt1ZLrJ1h2Bvz4FKapYwSiYERxCUpGZqSg1e7/2vLYMlbbs7ujNw2uZbuKH13wZB9Y QKzIHAvbyj/dgxQm0vmi3BI3CkIkQ54ZgiwrS52oQDoSZ8qlMuS4wVf9vF/XVxOJI7VP Dj177wbQ64MvhULirn9Uyd8l8hAnM/3dh5OH23MValxx7I5uRJWfzz8SyXPN8govyUb+ NSnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=9sAxqiey4hf1CXuyus/IItVeoeJbAL3YKzXoYMrVj+A=; b=nKgafoEPkHDPpEzDPWfYaO0XSBmB9OC+H7o72DGxFbdOWD+Hdaq1ObesRAtAySLsIR STpbr2OCl5dUhM0wU7mhFmzPvizaYXdNqCwTA6oEn0gycmQrhPPLNqzgBSxutYzUa5zt G1q6Lfh3EYU1IL6Wvi7UUitrsSSgt0zItIfzTRtoUPOGFHWTvBnPvFydsCd4MXnaemr2 mfy6fI7+wbeXz9X5WmTfpqsu+qSmrGVnjCfW/9C1texhSyh1xYP+e7OlZpQRbmluBni8 PJ/cMvEPQGCCv7OY/T8Yb6AwE6uqRDg0MTKZ20Cs65Q8hCNLnWFdJznB0HfeAUEF/0SJ UQxQ== X-Gm-Message-State: AD7BkJK2hSWVFegj3y5zfzcZbDna/7K9A5/Hj1bgPQSyJdlJ7jnW7Rf6rW4mYCPKDPCh+K1PLlwUUPFojjiY9w== MIME-Version: 1.0 X-Received: by 10.112.166.3 with SMTP id zc3mr4403676lbb.129.1460209519626; Sat, 09 Apr 2016 06:45:19 -0700 (PDT) Received: by 10.25.22.194 with HTTP; Sat, 9 Apr 2016 06:45:19 -0700 (PDT) In-Reply-To: References: Date: Sat, 9 Apr 2016 15:45:19 +0200 Message-ID: From: Jesper Wramberg To: Murad.Kablan@colorado.edu Cc: users Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-users] How to change IP and port in packet header and recalculate checksum X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Apr 2016 13:45:20 -0000 Hey Murad, Are you running DPDK on the receiving end as well ? In any case, I'm guessing you forgot to convert to network byte order ? :-) 2016-04-09 12:34 GMT+02:00 Murad Kablan : > Hi, > I'm trying to change the IP and port of packets before sending them out. > The captured packet in the receiving machines seems to be corrupted as the > port is different than the one I inserted. Am I doing the checksum right? > And do I need to do other HW configurations? > > This is my code: > struct udp_hdr *udp_h; > struct ipv4_hdr *ipv4_h; > struct ether_hdr *eth_hdr; > eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); > ipv4_h = (struct ipv4_hdr *)(eth_hdr + 1); > udp_h = (struct udp_hdr *)((unsigned char *)ipv4_h + sizeof(struct > ipv4_hdr)); > > ipv4_h->dst_addr = 6777226 //(gateway-ip 10.77.0.51) > udp_h->src_port = 88 > ipv4_h->hdr_checksum = 0; > udp_h->dgram_cksum = 0; > udp_h->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_h, udp_h); > ipv4_h->hdr_checksum = rte_ipv4_cksum(ipv4_h); > l2fwd_simple_forward(m, 0); > > Thanks, > > Murad >