From patchwork Tue Nov 20 10:26:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lam, Tiago" X-Patchwork-Id: 48200 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 14BA72BD5; Tue, 20 Nov 2018 11:26:50 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C08AD1D7 for ; Tue, 20 Nov 2018 11:26:47 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 02:26:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,256,1539673200"; d="scan'208";a="90712025" Received: from silpixa00399125.ir.intel.com ([10.237.223.34]) by orsmga007.jf.intel.com with ESMTP; 20 Nov 2018 02:26:44 -0800 From: Tiago Lam To: dev@dpdk.org Cc: ferruh.yigit@intel.com, linville@tuxdriver.com, Tiago Lam Date: Tue, 20 Nov 2018 10:26:29 +0000 Message-Id: <1542709592-215007-1-git-send-email-tiago.lam@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542707697-175836-1-git-send-email-tiago.lam@intel.com> References: <1542707697-175836-1-git-send-email-tiago.lam@intel.com> Subject: [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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Signed-off-by: Tiago Lam Reviewed-by: Ferruh Yigit --- 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;