Module Name:    src
Committed By:   maxv
Date:           Sun Jan 14 17:43:55 UTC 2018

Modified Files:
        src/sys/dev/pci: if_vge.c

Log Message:
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.61 src/sys/dev/pci/if_vge.c:1.62
--- src/sys/dev/pci/if_vge.c:1.61	Tue Sep 26 07:42:06 2017
+++ src/sys/dev/pci/if_vge.c	Sun Jan 14 17:43:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -358,64 +358,6 @@ vge_set_rxaddr(struct vge_rxdesc *rxd, b
 }
 
 /*
- * Defragment mbuf chain contents to be as linear as possible.
- * Returns new mbuf chain on success, NULL on failure. Old mbuf
- * chain is always freed.
- * XXX temporary until there would be generic function doing this.
- */
-#define m_defrag	vge_m_defrag
-struct mbuf * vge_m_defrag(struct mbuf *, int);
-
-struct mbuf *
-vge_m_defrag(struct mbuf *mold, int flags)
-{
-	struct mbuf *m0, *mn, *n;
-	size_t sz = mold->m_pkthdr.len;
-
-#ifdef DIAGNOSTIC
-	if ((mold->m_flags & M_PKTHDR) == 0)
-		panic("m_defrag: not a mbuf chain header");
-#endif
-
-	MGETHDR(m0, flags, MT_DATA);
-	if (m0 == NULL)
-		return NULL;
-	m0->m_pkthdr.len = mold->m_pkthdr.len;
-	mn = m0;
-
-	do {
-		if (sz > MHLEN) {
-			MCLGET(mn, M_DONTWAIT);
-			if ((mn->m_flags & M_EXT) == 0) {
-				m_freem(m0);
-				return NULL;
-			}
-		}
-
-		mn->m_len = MIN(sz, MCLBYTES);
-
-		m_copydata(mold, mold->m_pkthdr.len - sz, mn->m_len,
-		     mtod(mn, void *));
-
-		sz -= mn->m_len;
-
-		if (sz > 0) {
-			/* need more mbufs */
-			MGET(n, M_NOWAIT, MT_DATA);
-			if (n == NULL) {
-				m_freem(m0);
-				return NULL;
-			}
-
-			mn->m_next = n;
-			mn = n;
-		}
-	} while (sz > 0);
-
-	return m0;
-}
-
-/*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
 static uint16_t

Reply via email to