diff options
author | silby <silby@FreeBSD.org> | 2003-04-15 02:14:43 +0000 |
---|---|---|
committer | silby <silby@FreeBSD.org> | 2003-04-15 02:14:43 +0000 |
commit | 0c01d3cc3f47207be9f588d9f978ad3693bb8340 (patch) | |
tree | f8aa7a688c83ed227497dc9023ba139b57e028df /sys/kern/uipc_mbuf.c | |
parent | 1a58aa967827e55b7062b5cc45de8bbef3f21d65 (diff) | |
download | FreeBSD-src-0c01d3cc3f47207be9f588d9f978ad3693bb8340.zip FreeBSD-src-0c01d3cc3f47207be9f588d9f978ad3693bb8340.tar.gz |
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.
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 08a7246..8810358 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -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); |