From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E6ACA0547; Thu, 21 Oct 2021 11:18:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 967F44118E; Thu, 21 Oct 2021 11:18:21 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 6E83A40142 for ; Thu, 21 Oct 2021 11:18:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634807899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NDHEg1RmKS2z2051iKJNm+UxEod3cRX0l35h5hmZNMA=; b=ci0Kcj263k9WqohtYao25Ts+wElRAW+JJZC/LMuSOnGZUHxOIFEJYQp3OZVUAtnlvkoNnc cz+gsr/0v3b8xo7DH1nxkXp40PPOCHH+nzBUCEindWZ02qcZfquBp3Aj3H8cmM5+vgUQlH OKUMj7TrDQi1LeDGi1XEpLK9MizwHaQ= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-AXzHbAh-M0eDfRU0GggPZQ-1; Thu, 21 Oct 2021 05:18:18 -0400 X-MC-Unique: AXzHbAh-M0eDfRU0GggPZQ-1 Received: by mail-lf1-f69.google.com with SMTP id bi16-20020a0565120e9000b003fd56ef5a94so5411lfb.3 for ; Thu, 21 Oct 2021 02:18:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NDHEg1RmKS2z2051iKJNm+UxEod3cRX0l35h5hmZNMA=; b=hTUOnavCu4hOBZ2zc/JlZ3JbGGXjhMQTHDuOJgZrZUYgXmIfkf8IoxNcPL9+28VGX7 K6iNfXzIOfbs1AhxolaZASORhehhjt9OL7pQ2Ku75sU/Ft5sLcX6aHA9UOvbet1hHI5/ TrEwlkPURa95rLoth8rU2sAyp+VuOuOggnRwcMEDIhnSnWs9IFWsmO1BOpMEJBWnSe4p 59YKliXRwZN6gyvRnJiPEGhSZUOujTvjG+EMFKdDdvU3FfIa5AJRcA4q7xGjtEpNffid 3V8pawo9ihiDhJyJLr6ZS8f5AqKEsiDM/wKDvCT0ySLuHv+AYrA6MbDazr9swubBhBer l/2Q== X-Gm-Message-State: AOAM532EWYReUCVi5tf0Kcm8l73meQ2TOpK3aZkvo/ioFHlfi6+arkSh CoMgkHtPDpOSbfRfqnxB7nJyvB7lFd6h9stV7Q3I18C7/DJ+ddM0+WWkzEoIeGs2O5zPghvMhIz cAic/KyDnxOjOxnOaTqE= X-Received: by 2002:ac2:4bc1:: with SMTP id o1mr4211154lfq.553.1634807896841; Thu, 21 Oct 2021 02:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLEDS1s+bFBc1PY7Cspv4fhcyytpPzRrdz65cKHVBFIa6dRZVOHpEEFywGxiskxualkx1w7NLWQ+au2qGoceg= X-Received: by 2002:ac2:4bc1:: with SMTP id o1mr4211046lfq.553.1634807895206; Thu, 21 Oct 2021 02:18:15 -0700 (PDT) MIME-Version: 1.0 References: <20210113132734.1636-1-olivier.matz@6wind.com> <20210929213707.17727-1-olivier.matz@6wind.com> In-Reply-To: <20210929213707.17727-1-olivier.matz@6wind.com> From: David Marchand Date: Thu, 21 Oct 2021 11:18:03 +0200 Message-ID: To: Olivier Matz Cc: dev , Ajit Khaparde , ajitkhaparde@gmail.com, Ali Alnubani , Andrew Rybchenko , "Ananyev, Konstantin" , =?UTF-8?Q?Morten_Br=C3=B8rup?= , dpdk stable , Slava Ovsiienko Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v5] mbuf: fix reset on mbuf free X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Sep 29, 2021 at 11:37 PM Olivier Matz wrot= e: > > m->nb_seg must be reset on mbuf free whatever the value of m->next, > because it can happen that m->nb_seg is !=3D 1. For instance in this > case: > > m1 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m1, 500); > m2 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m2, 500); > rte_pktmbuf_chain(m1, m2); > m0 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m0, 500); > rte_pktmbuf_chain(m0, m1); > > As rte_pktmbuf_chain() does not reset nb_seg in the initial m1 > segment (this is not required), after this code the mbuf chain > have 3 segments: > - m0: next=3Dm1, nb_seg=3D3 > - m1: next=3Dm2, nb_seg=3D2 > - m2: next=3DNULL, nb_seg=3D1 > > Then split this chain between m1 and m2, it would result in 2 packets: > - first packet > - m0: next=3Dm1, nb_seg=3D2 > - m1: next=3DNULL, nb_seg=3D2 > - second packet > - m2: next=3DNULL, nb_seg=3D1 > > Freeing the first packet will not restore nb_seg=3D1 in the second > segment. This is an issue because it is expected that mbufs stored > in pool have their nb_seg field set to 1. > > Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool") > Cc: stable@dpdk.org > > Signed-off-by: Olivier Matz > Acked-by: Morten Br=C3=B8rup > Acked-by: Ajit Khaparde > Acked-by: Konstantin Ananyev Tested-by: Ali Alnubani Applied, thanks. --=20 David Marchand