svn commit: r304390 - in stable/10/sys/dev/ntb: . if_ntb

Alexander Motin mav at FreeBSD.org
Thu Aug 18 10:45:17 UTC 2016


Author: mav
Date: Thu Aug 18 10:45:15 2016
New Revision: 304390
URL: https://svnweb.freebsd.org/changeset/base/304390

Log:
  MFC r302495: Improve memory allocation errors handling on receive.

Modified:
  stable/10/sys/dev/ntb/if_ntb/if_ntb.c
  stable/10/sys/dev/ntb/ntb_transport.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- stable/10/sys/dev/ntb/if_ntb/if_ntb.c	Thu Aug 18 10:44:35 2016	(r304389)
+++ stable/10/sys/dev/ntb/if_ntb/if_ntb.c	Thu Aug 18 10:45:15 2016	(r304390)
@@ -241,7 +241,12 @@ ntb_net_rx_handler(struct ntb_transport_
 	struct mbuf *m = data;
 	struct ifnet *ifp = qp_data;
 
-	CTR0(KTR_NTB, "RX: rx handler");
+	CTR1(KTR_NTB, "RX: rx handler (%d)", len);
+	if (len < 0) {
+		if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+		return;
+	}
+
 	m->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID;
 	(*ifp->if_input)(ifp, m);
 }

Modified: stable/10/sys/dev/ntb/ntb_transport.c
==============================================================================
--- stable/10/sys/dev/ntb/ntb_transport.c	Thu Aug 18 10:44:35 2016	(r304389)
+++ stable/10/sys/dev/ntb/ntb_transport.c	Thu Aug 18 10:45:15 2016	(r304390)
@@ -881,6 +881,8 @@ ntb_memcpy_rx(struct ntb_transport_qp *q
 	CTR2(KTR_NTB, "RX: copying %d bytes from offset %p", len, offset);
 
 	entry->buf = (void *)m_devget(offset, len, 0, ifp, NULL);
+	if (entry->buf == NULL)
+		entry->len = -ENOMEM;
 
 	/* Ensure that the data is globally visible before clearing the flag */
 	wmb();


More information about the svn-src-stable-10 mailing list