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. :)
This commit is contained in:
parent
94c35e0af2
commit
9d9edc5693
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112591
@ -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
|
||||
|
@ -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 @@ ip_output(m0, opt, ro, flags, imo, inp)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user