Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/85452/?format=api
http://patches.dpdk.org/api/patches/85452/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20201218125238.13074-1-olivier.matz@6wind.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20201218125238.13074-1-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20201218125238.13074-1-olivier.matz@6wind.com", "date": "2020-12-18T12:52:37", "name": "[v2] mbuf: fix reset on mbuf free", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f39fb78dc96ea03024e4d54fa6a1696be16ce356", "submitter": { "id": 8, "url": "http://patches.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": { "id": 24651, "url": "http://patches.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20201218125238.13074-1-olivier.matz@6wind.com/mbox/", "series": [ { "id": 14371, "url": "http://patches.dpdk.org/api/series/14371/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=14371", "date": "2020-12-18T12:52:37", "name": "[v2] mbuf: fix reset on mbuf free", "version": 2, "mbox": "http://patches.dpdk.org/series/14371/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/85452/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/85452/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 3F711A09FD;\n\tFri, 18 Dec 2020 13:53:07 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id AC4C3CAE0;\n\tFri, 18 Dec 2020 13:52:43 +0100 (CET)", "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 3A18BCAAF;\n Fri, 18 Dec 2020 13:52:41 +0100 (CET)", "from glumotte.dev.6wind.com. (unknown [10.16.0.195])\n by proxy.6wind.com (Postfix) with ESMTP id 176BC4AC307;\n Fri, 18 Dec 2020 13:52:41 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Cc": "andrew.rybchenko@oktetlabs.ru, konstantin.ananyev@intel.com,\n mb@smartsharesystems.com, stable@dpdk.org", "Date": "Fri, 18 Dec 2020 13:52:37 +0100", "Message-Id": "<20201218125238.13074-1-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20201104170007.8026-1-olivier.matz@6wind.com>", "References": "<20201104170007.8026-1-olivier.matz@6wind.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v2] mbuf: fix reset on mbuf free", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "m->nb_seg must be reset on mbuf free whatever the value of m->next,\nbecause it can happen that m->nb_seg is != 1. For instance in this\ncase:\n\n m1 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m1, 500);\n m2 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m2, 500);\n rte_pktmbuf_chain(m1, m2);\n m0 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m0, 500);\n rte_pktmbuf_chain(m0, m1);\n\nAs rte_pktmbuf_chain() does not reset nb_seg in the initial m1\nsegment (this is not required), after this code the mbuf chain\nhave 3 segments:\n - m0: next=m1, nb_seg=3\n - m1: next=m2, nb_seg=2\n - m2: next=NULL, nb_seg=1\n\nThen split this chain between m1 and m2, it would result in 2 packets:\n - first packet\n - m0: next=m1, nb_seg=3\n - m1: next=m2, nb_seg=2\n - second packet\n - m2: next=NULL, nb_seg=1\n\nFreeing the first packet will not restore nb_seg=1 in the second\nsegment. This is an issue because it is expected that mbufs stored\nin pool have their nb_seg field set to 1.\n\nFixes: 8f094a9ac5d7 (\"mbuf: set mbuf fields while in pool\")\nCc: stable@dpdk.org\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n lib/librte_mbuf/rte_mbuf.c | 4 ++--\n lib/librte_mbuf/rte_mbuf.h | 8 ++++----\n lib/librte_mbuf/rte_mbuf_core.h | 13 +++++++++++--\n 3 files changed, 17 insertions(+), 8 deletions(-)", "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 7d09ee2939..5f77840557 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -129,10 +129,10 @@ rte_pktmbuf_free_pinned_extmem(void *addr, void *opaque)\n \n \trte_mbuf_ext_refcnt_set(m->shinfo, 1);\n \tm->ol_flags = EXT_ATTACHED_MBUF;\n-\tif (m->next != NULL) {\n+\tif (m->next != NULL)\n \t\tm->next = NULL;\n+\tif (m->nb_segs != 1)\n \t\tm->nb_segs = 1;\n-\t}\n \trte_mbuf_raw_free(m);\n }\n \ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex c4c9ebfaa0..8c1097ed76 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1340,10 +1340,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \t\t\t\treturn NULL;\n \t\t}\n \n-\t\tif (m->next != NULL) {\n+\t\tif (m->next != NULL)\n \t\t\tm->next = NULL;\n+\t\tif (m->nb_segs != 1)\n \t\t\tm->nb_segs = 1;\n-\t\t}\n \n \t\treturn m;\n \n@@ -1357,10 +1357,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \t\t\t\treturn NULL;\n \t\t}\n \n-\t\tif (m->next != NULL) {\n+\t\tif (m->next != NULL)\n \t\t\tm->next = NULL;\n+\t\tif (m->nb_segs != 1)\n \t\t\tm->nb_segs = 1;\n-\t\t}\n \t\trte_mbuf_refcnt_set(m, 1);\n \n \t\treturn m;\ndiff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h\nindex 567551deab..78a1fcc8ff 100644\n--- a/lib/librte_mbuf/rte_mbuf_core.h\n+++ b/lib/librte_mbuf/rte_mbuf_core.h\n@@ -495,7 +495,12 @@ struct rte_mbuf {\n \t * or non-atomic) is controlled by the RTE_MBUF_REFCNT_ATOMIC flag.\n \t */\n \tuint16_t refcnt;\n-\tuint16_t nb_segs; /**< Number of segments. */\n+\n+\t/**\n+\t * Number of segments. Only valid for the first segment of an mbuf\n+\t * chain.\n+\t */\n+\tuint16_t nb_segs;\n \n \t/** Input port (16 bits to support more than 256 virtual ports).\n \t * The event eth Tx adapter uses this field to specify the output port.\n@@ -591,7 +596,11 @@ struct rte_mbuf {\n \t/* second cache line - fields only used in slow path or on TX */\n \tRTE_MARKER cacheline1 __rte_cache_min_aligned;\n \n-\tstruct rte_mbuf *next; /**< Next segment of scattered packet. */\n+\t/**\n+\t * Next segment of scattered packet. Must be NULL in the last segment or\n+\t * in case of non-segmented packet.\n+\t */\n+\tstruct rte_mbuf *next;\n \n \t/* fields to support TX offloads */\n \tRTE_STD_C11\n", "prefixes": [ "v2" ] }{ "id": 85452, "url": "