Add another MBUF_STRESS_TEST feature, m_defragrandomfailures.

When enabled, this causes m_defrag to randomly return NULL (following
its normal failure case so that extra memory leaks are not introduced.)

Code similar to this was used to find / fix a few bugs last week.
This commit is contained in:
Mike Silbersack 2003-04-15 02:14:43 +00:00
parent acbff226fc
commit 352d050e79
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113490

View file

@ -36,6 +36,7 @@
#include "opt_mac.h"
#include "opt_param.h"
#include "opt_mbuf_stress_test.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -56,6 +57,9 @@ int m_defragpackets;
int m_defragbytes;
int m_defraguseless;
int m_defragfailure;
#ifdef MBUF_STRESS_TEST
int m_defragrandomfailures;
#endif
/*
* sysctl(8) exported objects
@ -76,6 +80,10 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, m_defraguseless, CTLFLAG_RD,
&m_defraguseless, 0, "");
SYSCTL_INT(_kern_ipc, OID_AUTO, m_defragfailure, CTLFLAG_RD,
&m_defragfailure, 0, "");
#ifdef MBUF_STRESS_TEST
SYSCTL_INT(_kern_ipc, OID_AUTO, m_defragrandomfailures, CTLFLAG_RW,
&m_defragrandomfailures, 0, "");
#endif
/*
* "Move" mbuf pkthdr from "from" to "to".
@ -802,6 +810,13 @@ m_defrag(struct mbuf *m0, int how)
if (!(m0->m_flags & M_PKTHDR))
return (m0);
#ifdef MBUF_STRESS_TEST
if (m_defragrandomfailures) {
int temp = arc4random() & 0xff;
if (temp == 0xba)
goto nospace;
}
#endif
if (m0->m_pkthdr.len > MHLEN)
m_final = m_getcl(how, MT_DATA, M_PKTHDR);