summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsilby <silby@FreeBSD.org>2003-03-25 05:45:05 +0000
committersilby <silby@FreeBSD.org>2003-03-25 05:45:05 +0000
commit7cb68ba07423313b147ba372535629d2e5819c62 (patch)
treeb3eb631f10bf32ee58b55fe077fad530c8b8ad39
parent012abb85fbb76e777aca3b02c1b9fc912a074ca0 (diff)
downloadFreeBSD-src-7cb68ba07423313b147ba372535629d2e5819c62.zip
FreeBSD-src-7cb68ba07423313b147ba372535629d2e5819c62.tar.gz
Add the MBUF_FRAG_TEST option. When compiled in, this option
allows you to tell ip_output to fragment all outgoing packets into mbuf fragments of size net.inet.ip.mbuf_frag_size bytes. This is an excellent way to test if network drivers can properly handle long mbuf chains being passed to them. net.inet.ip.mbuf_frag_size defaults to 0 (no fragmentation) so that you can at least boot before your network driver dies. :)
-rw-r--r--sys/conf/options1
-rw-r--r--sys/netinet/ip_output.c30
2 files changed, 31 insertions, 0 deletions
diff --git a/sys/conf/options b/sys/conf/options
index 1024a5d..82f2fce 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -360,6 +360,7 @@ SLIP_IFF_OPTS opt_slip.h
TCPDEBUG
TCP_DROP_SYNFIN opt_tcp_input.h
XBONEHACK
+MBUF_FRAG_TEST opt_mbuf_frag_test.h
# Netgraph(4). Use option NETGRAPH to enable the base netgraph code.
# Each netgraph node type can be either be compiled into the kernel
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 9877964..02fb2d3 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -42,6 +42,7 @@
#include "opt_mac.h"
#include "opt_pfil_hooks.h"
#include "opt_random_ip_id.h"
+#include "opt_mbuf_frag_test.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -52,6 +53,7 @@
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -94,6 +96,12 @@ static MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "internet multicast options");
u_short ip_id;
+#ifdef MBUF_FRAG_TEST
+int mbuf_frag_size = 0;
+SYSCTL_INT(_net_inet_ip, OID_AUTO, mbuf_frag_size, CTLFLAG_RW,
+ &mbuf_frag_size, 0, "Fragment outgoing mbufs to this size");
+#endif
+
static struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *);
static struct ifnet *ip_multicast_if(struct in_addr *, int *);
static void ip_mloopback
@@ -1012,6 +1020,28 @@ pass:
ipsec_delaux(m);
#endif
+#ifdef MBUF_FRAG_TEST
+ if (mbuf_frag_size) {
+ struct mbuf *m1, *m2;
+ int length;
+
+ length = m->m_len;
+
+ while (1) {
+ length -= mbuf_frag_size;
+ if (length < 1)
+ break;
+ m1 = m_split(m, length, M_DONTWAIT);
+ m2 = m;
+ while (1) {
+ if (m2->m_next == NULL)
+ break;
+ m2 = m2->m_next;
+ }
+ m2->m_next = m1;
+ }
+ }
+#endif
error = (*ifp->if_output)(ifp, m,
(struct sockaddr *)dst, ro->ro_rt);
goto done;
OpenPOWER on IntegriCloud