From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by dpdk.org (Postfix) with ESMTP id DEB767EEF for ; Fri, 6 Mar 2015 01:10:52 +0100 (CET) Received: by padfa1 with SMTP id fa1so46651705pad.9 for ; Thu, 05 Mar 2015 16:10:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y669HLFXI6k6CaWimIirZRjWwhM0kyx/eY9OTxY1mHc=; b=Oxd0xYO2N/BRY+1qR8wzyJ3Kv16oM06NjKe8tC5FX4Lg4aRB6ZweB/h6EzPS2xESRA 2t1iS55Zzer6W76V9F7amAiCALhGfTR8ET1gnRbulQgt4n4giuMDryJDIYe8TMUFJolB yt7zWIwCioS2eRyUUzb1Cu9s0kaIbi7GUp8fgPRj+UV5gk7raVdzsis0ONNuFc+tsSXm PI1za5R1ubGsHm23hcKGN0xrGLkm6f4CgtBasM+hUxT+qPUnpHfPUCvYCWEQRJb4ScTx aRwA7QQeR/jhCFfXni47X0yw0O7aY0tu6qMr6KlE4nnqBYkXwhm2Q3KokBmkakVAb+Hk 3QFA== X-Gm-Message-State: ALoCoQnavHqqrP4+Ijf8GL3HUJVEfVXfu2cAU0+ANj/WefI8LJ3iH5NTlY2+p223MEcmiQX9Ouks X-Received: by 10.70.22.137 with SMTP id d9mr20332073pdf.135.1425600652272; Thu, 05 Mar 2015 16:10:52 -0800 (PST) Received: from urahara.brocade.com (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id ms5sm7940550pbb.59.2015.03.05.16.10.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Mar 2015 16:10:51 -0800 (PST) From: Stephen Hemminger To: Yong Wang Date: Thu, 5 Mar 2015 16:10:34 -0800 Message-Id: <1425600635-20628-10-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425600635-20628-1-git-send-email-stephen@networkplumber.org> References: <1425600635-20628-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org, Stephen Hemminger Subject: [dpdk-dev] [PATCH v3 09/10] vmxnet3: add check for jumbo segment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2015 00:10:53 -0000 From: Stephen Hemminger It is possible that some rogue application might pass a segment larger than 16K to the vmxnet3 transmit routine. In which case just drop it and increment counter. Signed-off-by: Stephen Hemminger --- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 1 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ring.h b/lib/librte_pmd_vmxnet3/vmxnet3_ring.h index 55ceadf..5cdcb23 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_ring.h +++ b/lib/librte_pmd_vmxnet3/vmxnet3_ring.h @@ -126,6 +126,7 @@ struct vmxnet3_txq_stats { * different reasons */ uint64_t drop_too_many_segs; + uint64_t drop_too_big; uint64_t drop_tso; uint64_t tx_ring_full; }; diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c index 3bd13ef..f6c3452 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c @@ -327,6 +327,17 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq) PMD_TX_LOG(DEBUG, "Processed %d tx comps & command descs.", completed); } +static inline int +vmxnet3_seg_too_big(const struct rte_mbuf *m) +{ + do { + if (m->data_len > VMXNET3_MAX_TX_BUF_SIZE) + return 1; + } while ((m = m->next) != NULL); + + return 0; +} + uint16_t vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -353,6 +364,13 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, /* Is this packet execessively fragmented, then drop */ if (unlikely(txm->nb_segs > VMXNET3_MAX_TXD_PER_PKT)) { ++txq->stats.drop_too_many_segs; + goto drop; + } + + /* Check for case of monster segment */ + if (unlikely(vmxnet3_seg_too_big(txm))) { + ++txq->stats.drop_too_big; + drop: ++txq->stats.drop_total; rte_pktmbuf_free(txm); ++nb_tx; -- 2.1.4