svn commit: r302495 - in head/sys/dev/ntb: . if_ntb

Alexander Motin mav at FreeBSD.org
Sat Jul 9 12:00:05 UTC 2016


Author: mav
Date: Sat Jul  9 12:00:04 2016
New Revision: 302495
URL: https://svnweb.freebsd.org/changeset/base/302495

Log:
  Improve memory allocation errors handling on receive.

Modified:
  head/sys/dev/ntb/if_ntb/if_ntb.c
  head/sys/dev/ntb/ntb_transport.c

Modified: head/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- head/sys/dev/ntb/if_ntb/if_ntb.c	Sat Jul  9 11:58:59 2016	(r302494)
+++ head/sys/dev/ntb/if_ntb/if_ntb.c	Sat Jul  9 12:00:04 2016	(r302495)
@@ -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: head/sys/dev/ntb/ntb_transport.c
==============================================================================
--- head/sys/dev/ntb/ntb_transport.c	Sat Jul  9 11:58:59 2016	(r302494)
+++ head/sys/dev/ntb/ntb_transport.c	Sat Jul  9 12:00:04 2016	(r302495)
@@ -877,6 +877,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-head mailing list