From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua0-f172.google.com (mail-ua0-f172.google.com [209.85.217.172]) by dpdk.org (Postfix) with ESMTP id 3F9352BAA for ; Wed, 10 May 2017 21:12:31 +0200 (CEST) Received: by mail-ua0-f172.google.com with SMTP id e55so6268841uaa.2 for ; Wed, 10 May 2017 12:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=5ZrDAkJ2YGrenK1tfICKPQXYzgOSzAuVDHyzxO+XsiE=; b=jmI6NeKLdJtalzUuj3Drx2BgIxyPNVI5R5fWNFdJefWREjFYnTVwLYHF1AC7/xaLGc D3gBTRn01I4UPohqFXQmPLX6ThZxeREI1WOEU6DUxZC3hnK9jNoW7PBKyZIYk47iMwoU hKtH92kWCDzAijX6lIKGEepNVDCQlidjGZva3n6LZH1McPnmvQHy2E8gRFuAwOq/50Kp 32Ea2VlcmRCJPM00OjIwWFGXHDAA7vlEjqX+QUOnkfmwPPhanJeBbj3Xl3iVBiB1/dn/ c2Sc9iUo28FCKnKH2I+n3OL0rbxgkS4enxOZuJmIBLmRZB7GvWbwx0PSd/4NhAW5RUO5 JVKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5ZrDAkJ2YGrenK1tfICKPQXYzgOSzAuVDHyzxO+XsiE=; b=eGuk+CQ48Yy3QV7tsireA/6cgO82cTJuSoGppj9myekkYJLA8XrvbAo/tg3gOY0+pV h+uVpj8iqRDL3tdMmknKyveed4dTNekzH7/6D99m0+gBTIkM6oIJ0D24z6mp+lzNkvSg 84i1PbU9iLF7Y0aZXb+AvULzv28YK7AtZtDx1W5kGJ2T/t2W34RdmeWgjkp6mlxPz0gm ObCxwLevB5AanRN4WIWb7iJciktwAMr2U20WIM4oOB5g33uKoAsrN5ENcNdoaBYjQAMf 0de8Ip0yFOJvffoHA6V6vl69fWfi+zlXBha5uWHXVaeEMjpMjFYJUrUHKkfj9pO3QwGs NvuA== X-Gm-Message-State: AODbwcDpw3/RzfA57veE01KesZSqwYXkddEnLCJMtp7rx4EVsVylZg5e vQJ/EEsFm+cOLFMSWvD2uPw3BITiASAwekM= X-Received: by 10.176.80.162 with SMTP id c31mr2995349uaa.25.1494443550383; Wed, 10 May 2017 12:12:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.85.220 with HTTP; Wed, 10 May 2017 12:12:29 -0700 (PDT) From: Harold Demure Date: Wed, 10 May 2017 21:12:29 +0200 Message-ID: To: users@dpdk.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-users] IPV4 frag/defrag X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 May 2017 19:12:31 -0000 Hello, In my application I have to send pieces of data that won't fit a single ethernet frame. To this end I am reimplementing a sort-of ipv4 frag/defrag protocol. Namely, I am spreading my app-level payload across several ipv4 packets and to keep track of the sequence numbers within my packet I use the fragment_offset field in the struct ipv4_hdr. (I am aware my approach is not the correct and portable one, but I would like to see a dirty code working before refining it). However, as soon as I assign any value different from zero to fragment_offset, I do not see the packets being received anymore. Do you have any idea of what I am doing wrong? The function I use to inizialize the ipv4 header is below. Everything works fine as long as segment_index is 0 AND more_frag is false. Thank you for your help. Regards, Harold ---- My config Network card is a MLX4 DPDK version is 2.2.0 Linux distro is Ubuntu 16.04 Network driver is MLNX_OFED_LINUX-4.0-2.0.0.1 ------- static inline uint16_t initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr, uint32_t dst_addr, uint16_t pkt_data_len, u16 segment_index, u16 pckt_id, bool more_frag) { uint16_t pkt_len; uint16_t *ptr16; uint32_t ip_cksum; /* * Initialize IP header. */ pkt_len = (uint16_t)(pkt_data_len + sizeof(struct ipv4_hdr)); ip_hdr->version_ihl = 0x40 | 0x05; ip_hdr->type_of_service = 0; if (more_frag) { ip_hdr->fragment_offset = (uint16_t)( rte_cpu_to_be_16(segment_index)| IPV4_HDR_MF_FLAG); } else { ip_hdr->fragment_offset = (uint16_t)( rte_cpu_to_be_16(segment_index)); } ip_hdr->time_to_live = IP_DEFTTL; ip_hdr->next_proto_id = IPPROTO_UDP; ip_hdr->packet_id = pckt_id; ip_hdr->total_length = rte_cpu_to_be_16(pkt_len); ip_hdr->src_addr = rte_cpu_to_be_32(src_addr); ip_hdr->dst_addr = rte_cpu_to_be_32(dst_addr); /* * Compute IP header checksum. */ ptr16 = (uint16_t *) ip_hdr; ip_cksum = 0; ip_cksum += ptr16[0]; ip_cksum += ptr16[1]; ip_cksum += ptr16[2]; ip_cksum += ptr16[3]; ip_cksum += ptr16[4]; ip_cksum += ptr16[6]; ip_cksum += ptr16[7]; ip_cksum += ptr16[8]; ip_cksum += ptr16[9]; /* * Reduce 32 bit checksum to 16 bits and complement it. */ ip_cksum = ((ip_cksum & 0xFFFF0000) >> 16) + (ip_cksum & 0x0000FFFF); ip_cksum %= 65536; ip_cksum = (~ip_cksum) & 0x0000FFFF; if (ip_cksum == 0) ip_cksum = 0xFFFF; ip_hdr->hdr_checksum = (uint16_t) ip_cksum; return pkt_len; }