svn commit: r344472 - stable/11/sys/net

Stephen Hurd shurd at FreeBSD.org
Fri Feb 22 18:24:58 UTC 2019


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 at mattmacy.io> (this version of patch)
  Submitted by: Matthew Macy <mmacy at 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:


More information about the svn-src-all mailing list