Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2019 18:24:58 +0000 (UTC)
From:      Stephen Hurd <shurd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r344472 - stable/11/sys/net
Message-ID:  <201902221824.x1MIOwWS035510@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: shurd
Date: Fri Feb 22 18:24:57 2019
New Revision: 344472
URL: https://svnweb.freebsd.org/changeset/base/344472

Log:
  MFC r333131:
  
  Fix iflib_encap() EFBIG handling bugs
  
  1) Don't give up if m_collapse() fails.  Rather than giving up, try
  m_defrag() immediately.
  
  2) Fix a leak where, if the NIC driver rejected the defrag'ed chain
  as having too many segments, we would fail to free the chain.
  
  Reviewed by:  Matthew Macy <mmacy@mattmacy.io> (this version of patch)
  Submitted by: Matthew Macy <mmacy@mattmacy.io> (early version of leak fix)

Modified:
  stable/11/sys/net/iflib.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/net/iflib.c
==============================================================================
--- stable/11/sys/net/iflib.c	Fri Feb 22 18:02:46 2019	(r344471)
+++ stable/11/sys/net/iflib.c	Fri Feb 22 18:24:57 2019	(r344472)
@@ -3229,8 +3229,12 @@ defrag:
 		switch (err) {
 		case EFBIG:
 			/* try collapse once and defrag once */
-			if (remap == 0)
+			if (remap == 0) {
 				m_head = m_collapse(*m_headp, M_NOWAIT, max_segs);
+				/* try defrag if collapsing fails */
+				if (m_head == NULL)
+					remap++;
+			}
 			if (remap == 1)
 				m_head = m_defrag(*m_headp, M_NOWAIT);
 			remap++;
@@ -3318,13 +3322,18 @@ defrag:
 		 */
 		txq->ift_pidx = pi.ipi_new_pidx;
 		txq->ift_npending += pi.ipi_ndescs;
-	} else if (__predict_false(err == EFBIG && remap < 2)) {
+	} else {
 		*m_headp = m_head = iflib_remove_mbuf(txq);
-		remap = 1;
-		txq->ift_txd_encap_efbig++;
-		goto defrag;
-	} else
+		if (err == EFBIG) {
+			txq->ift_txd_encap_efbig++;
+			if (remap < 2) {
+				remap = 1;
+				goto defrag;
+			}
+		}
 		DBG_COUNTER_INC(encap_txd_encap_fail);
+		goto defrag_failed;
+	}
 	return (err);
 
 defrag_failed:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902221824.x1MIOwWS035510>