From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by dpdk.org (Postfix) with ESMTP id 382281B560 for ; Tue, 27 Nov 2018 05:56:19 +0100 (CET) Received: by mail-qt1-f194.google.com with SMTP id k12so20394190qtf.7 for ; Mon, 26 Nov 2018 20:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=iKMZ8NekPm+f6qRq+MVD7QskitkyRjuwx4S40TVDT5w=; b=F+rUVhcEB4VSx1nUd9q/QCFIX1xT8oG/NuNClbU0FNNOZyQ6NXcnCfg11OsiIssYac UZyvxSyglD0RvQXcaRgsgWojGfnRl4dLMFS9PXX/+pYIUuLmKMkxkFxBL9Z+fCbpL5x8 LpEvYGObu6mr4mJ9jY68PyjeUKzykxzBAFobhG4uv9aF8LnE1c9V6jHX5PKH6PGxQ7Nt ZABkCT4FxZVIJU3kOjc3kJtlmacGM5GefLIZqwcJGhHtdqdDEaO5h84oIkl95CUkkaWa ShN47unNA3SMaJ5f/eHgp0GDN39Beubu0BoygzelpfmihPLtgXk6y73isYwda0mYElvR l/0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iKMZ8NekPm+f6qRq+MVD7QskitkyRjuwx4S40TVDT5w=; b=odzvMgKLIhPa9t31tHD7u6jjHeNi7qbK1AQ1X/FV1hVitm7C8oz82wh2sc08TxTkyO i4ZF66XPnrRwbOQASyfi7bJK5+OHFTrgUcJxVUkFSEGZP04xt+bfu2ZDPhwicUs6ZSkH +Rq7MgyNW0KZbE7HkJw6sKqHFOZrt6S/TLbsk2tfbu/WF3PB6coGRwwr72Fkjzz7YfE1 vGb1wGzQqgmyGrcB+m86I1kjvdf1b+DuLPIY9clT2jkERdrYCU746orolfXTey9Yx7mO uwPK7UQrqyw84wrxSugpTunvasX4T+k/f0y8Sa2tEroO4l6Wr95six4O95fkjTLee9Hp Vh/A== X-Gm-Message-State: AGRZ1gL1iMweuO+qGi25mxFffTzMrGdyiGIixkdL+Yt2VVFt6yxKI9bh 2u6T2nZjNIs5EN9b9jjZ/BOVynmM X-Google-Smtp-Source: AJdET5e6f2NNTAyl9osORarKEC0oba+hvNZlk7AILQpVk66e+GBhnGixsRJvwD4LR07xZG0K2YV59g== X-Received: by 2002:aed:38c6:: with SMTP id k64mr27720946qte.97.1543294578367; Mon, 26 Nov 2018 20:56:18 -0800 (PST) Received: from monolith.fios-router.home (pool-96-255-82-34.washdc.fios.verizon.net. [96.255.82.34]) by smtp.gmail.com with ESMTPSA id 24sm1672925qkx.77.2018.11.26.20.56.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Nov 2018 20:56:17 -0800 (PST) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, Chas Williams Date: Mon, 26 Nov 2018 23:56:13 -0500 Message-Id: <20181127045613.16437-1-3chas3@gmail.com> X-Mailer: git-send-email 2.14.4 Subject: [dpdk-dev] [PATCH] ip_frag: fix ipv6 when MTU sizes not aligned to 8 bytes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2018 04:56:19 -0000 From: Chas Williams The same issue was fixed on for the ipv4 version of this routine in commit 8d4d3a4f7337 ("ip_frag: handle MTU sizes not aligned to 8 bytes"). Briefly, the size of an ipv6 header is always 40 bytes. With an MTU of 1500, this will never produce a multiple of 8 bytes for the frag_size and this routine can never succeed. Since RTE_ASSERTS are disabled by default, this failure is tpyically ignored. To fix this, round down to the nearest 8 bytes and use this when producing the fragments. Fixes: 0aa31d7a5929 ("ip_frag: add IPv6 fragmentation support") Signed-off-by: Chas Williams --- lib/librte_ip_frag/rte_ip_frag.h | 1 + lib/librte_ip_frag/rte_ipv6_fragmentation.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h index a4ccaf9d1..04fd9df52 100644 --- a/lib/librte_ip_frag/rte_ip_frag.h +++ b/lib/librte_ip_frag/rte_ip_frag.h @@ -115,6 +115,7 @@ struct rte_ip_frag_tbl { #define RTE_IPV6_EHDR_MF_MASK 1 #define RTE_IPV6_EHDR_FO_SHIFT 3 #define RTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1)) +#define RTE_IPV6_EHDR_FO_ALIGN (1 << RTE_IPV6_EHDR_FO_SHIFT) #define RTE_IPV6_FRAG_USED_MASK \ (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK) diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c index 62a7e4e83..b9437eb11 100644 --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c @@ -77,11 +77,14 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, uint32_t out_pkt_pos, in_seg_data_pos; uint32_t more_in_segs; uint16_t fragment_offset, frag_size; + uint64_t frag_bytes_remaining; - frag_size = (uint16_t)(mtu_size - sizeof(struct ipv6_hdr)); - - /* Fragment size should be a multiple of 8. */ - RTE_ASSERT((frag_size & ~RTE_IPV6_EHDR_FO_MASK) == 0); + /* + * Ensure the IP payload length of all fragments (except the + * the last fragment) are a multiple of 8 bytes per RFC2460. + */ + frag_size = RTE_ALIGN_FLOOR(mtu_size - sizeof(struct ipv6_hdr), + RTE_IPV6_EHDR_FO_ALIGN); /* Check that pkts_out is big enough to hold all fragments */ if (unlikely (frag_size * nb_pkts_out < @@ -111,6 +114,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, /* Reserve space for the IP header that will be built later */ out_pkt->data_len = sizeof(struct ipv6_hdr) + sizeof(struct ipv6_extension_fragment); out_pkt->pkt_len = sizeof(struct ipv6_hdr) + sizeof(struct ipv6_extension_fragment); + frag_bytes_remaining = frag_size; out_seg_prev = out_pkt; more_out_segs = 1; @@ -130,7 +134,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, /* Prepare indirect buffer */ rte_pktmbuf_attach(out_seg, in_seg); - len = mtu_size - out_pkt->pkt_len; + len = frag_bytes_remaining; if (len > (in_seg->data_len - in_seg_data_pos)) { len = in_seg->data_len - in_seg_data_pos; } @@ -140,11 +144,11 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, out_pkt->pkt_len); out_pkt->nb_segs += 1; in_seg_data_pos += len; + frag_bytes_remaining -= len; /* Current output packet (i.e. fragment) done ? */ - if (unlikely(out_pkt->pkt_len >= mtu_size)) { + if (unlikely(frag_bytes_remaining == 0)) more_out_segs = 0; - } /* Current input segment done ? */ if (unlikely(in_seg_data_pos == in_seg->data_len)) { -- 2.14.4