From owner-svn-src-head@freebsd.org Sun Jul 22 17:45:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09222105164F; Sun, 22 Jul 2018 17:45:46 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A43407D7A8; Sun, 22 Jul 2018 17:45:45 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7821A1131F; Sun, 22 Jul 2018 17:45:45 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6MHjj1P080706; Sun, 22 Jul 2018 17:45:45 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6MHjjAD080705; Sun, 22 Jul 2018 17:45:45 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201807221745.w6MHjjAD080705@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 22 Jul 2018 17:45:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336611 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: marius X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 336611 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jul 2018 17:45:46 -0000 Author: marius Date: Sun Jul 22 17:45:44 2018 New Revision: 336611 URL: https://svnweb.freebsd.org/changeset/base/336611 Log: - Given that the controlling expression of the receive loop in iflib_rxeof() tests for avail > 0, avail can never be 0 within that loop. Thus, move decrementing avail and budget_left into the loop and before the code which checks for additional descriptors having become available in case all the previous ones have been processed but there still is budget left so the latter code works as expected. [1] - In iflib_{busdma_load_mbuf_sg,parse_header}(), remove dead stores to m and n respectively. [2, 3] - In collapse_pkthdr(), ensure that m_next isn't NULL before dereferencing it. [4] - Remove a duplicate assignment of segs in iflib_encap(). Reported by: Coverity CID: 1356027 [1], 1356047 [2], 1368205 [3], 1356028 [4] Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c ============================================================================== --- head/sys/net/iflib.c Sun Jul 22 17:40:13 2018 (r336610) +++ head/sys/net/iflib.c Sun Jul 22 17:45:44 2018 (r336611) @@ -2663,7 +2663,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) return (false); } - for (budget_left = budget; (budget_left > 0) && (avail > 0); budget_left--, avail--) { + for (budget_left = budget; budget_left > 0 && avail > 0;) { if (__predict_false(!CTX_ACTIVE(ctx))) { DBG_COUNTER_INC(rx_ctx_inactive); break; @@ -2697,6 +2697,8 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) /* will advance the cidx on the corresponding free lists */ m = iflib_rxd_pkt_get(rxq, &ri); + avail--; + budget_left--; if (avail == 0 && budget_left) avail = iflib_rxd_avail(ctx, rxq, *cidxp, budget_left); @@ -2873,14 +2875,14 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct ether_vlan_header *eh; struct mbuf *m, *n; - n = m = *mp; + m = *mp; if ((sctx->isc_flags & IFLIB_NEED_SCRATCH) && M_WRITABLE(m) == 0) { if ((m = m_dup(m, M_NOWAIT)) == NULL) { return (ENOMEM); } else { m_freem(*mp); - n = *mp = m; + *mp = m; } } @@ -3048,6 +3050,8 @@ collapse_pkthdr(struct mbuf *m0) } m = m0; m->m_next = m_next; + if (m_next == NULL) + return (m); if ((m_next->m_flags & M_EXT) == 0) { m = m_defrag(m, M_NOWAIT); } else { @@ -3108,7 +3112,7 @@ iflib_busdma_load_mbuf_sg(iflib_txq_t txq, bus_dma_tag * Please don't ever do this */ if (__predict_false(m->m_len == 0)) - *m0 = m = collapse_pkthdr(m); + *m0 = collapse_pkthdr(m); ctx = txq->ift_ctx; sctx = ctx->ifc_sctx; @@ -3285,7 +3289,6 @@ iflib_encap(iflib_txq_t txq, struct mbuf **m_headp) int err, nsegs, ndesc, max_segs, pidx, cidx, next, ntxd; bus_dma_tag_t desc_tag; - segs = txq->ift_segs; ctx = txq->ift_ctx; sctx = ctx->ifc_sctx; scctx = &ctx->ifc_softc_ctx;