From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 4D2392BD5 for ; Tue, 20 Nov 2018 11:29:34 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96CB6307EA94; Tue, 20 Nov 2018 10:29:33 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8092060BE7; Tue, 20 Nov 2018 10:29:32 +0000 (UTC) To: Tiago Lam , dev@dpdk.org Cc: ferruh.yigit@intel.com, linville@tuxdriver.com References: <1542707697-175836-1-git-send-email-tiago.lam@intel.com> <1542709592-215007-1-git-send-email-tiago.lam@intel.com> From: Kevin Traynor Organization: Red Hat Message-ID: <4419c3e1-d94c-8cde-cf55-0e54a255b8c4@redhat.com> Date: Tue, 20 Nov 2018 10:29:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <1542709592-215007-1-git-send-email-tiago.lam@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 20 Nov 2018 10:29:33 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/af_packet: set_mtu() decrements sockaddr twice 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, 20 Nov 2018 10:29:34 -0000 On 11/20/2018 10:26 AM, Tiago Lam wrote: > When setting the MTU, eth_dev_mtu_set() is called to validate the > provided MTU. As part of that, it calculates the useful area to store > data and compares it against the MTU, to guarantee that there's enough > space to store the data. It calculates that as: > "tp_frame_size - TPACKET2_HDRLEN - sizeof(struct sockaddr_ll)" > > However, the TPACKET2_HDRLEN macro already increaments sizeof(struct > sockaddr_ll) internally, meaning the useuful area of data above will > have sizeof(struct sockaddr_ll) decremented twice. > > Instead, the useful area of data should be calculated as: > "tp_frame_size - TPACKET2_HDRLEN" > > This makes sure that there's enough useful area to fit the provided MTU > after excluding tpacket2_hdr and sockaddr_ll. > > Fixes: cc68ac4 ("net/af_packet: support MTU change") > It should be for stable also? > Signed-off-by: Tiago Lam > --- > drivers/net/af_packet/rte_eth_af_packet.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c > index 95a98c6..264cfc0 100644 > --- a/drivers/net/af_packet/rte_eth_af_packet.c > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > @@ -433,8 +433,7 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > int ret; > int s; > unsigned int data_size = internals->req.tp_frame_size - > - TPACKET2_HDRLEN - > - sizeof(struct sockaddr_ll); > + TPACKET2_HDRLEN; > > if (mtu > data_size) > return -EINVAL; >