--- linux-2.2.17pre5/net/core/sysctl_net_core.c Sun Nov 8 06:00:32 1998 +++ linux-akpm/net/core/sysctl_net_core.c Sat Jun 24 14:54:54 2000 @@ -23,6 +23,7 @@ extern int sysctl_core_destroy_delay; extern int sysctl_optmem_max; +extern int dev_alloc_fail; ctl_table core_table[] = { #ifdef CONFIG_NET @@ -54,6 +55,9 @@ &proc_dointvec_jiffies}, {NET_CORE_OPTMEM_MAX, "optmem_max", &sysctl_optmem_max, sizeof(int), 0644, NULL, + &proc_dointvec}, + {NET_CORE_DEV_ALLOC_FAIL, "dev_alloc_fail", + &dev_alloc_fail, sizeof(int), 0644, NULL, &proc_dointvec}, #endif /* CONFIG_NET */ { 0 } --- linux-2.2.17pre5/include/linux/sysctl.h Fri Jun 16 23:47:59 2000 +++ linux-akpm/include/linux/sysctl.h Sat Jun 24 14:53:31 2000 @@ -166,7 +166,8 @@ NET_CORE_FASTROUTE=7, NET_CORE_MSG_COST=8, NET_CORE_MSG_BURST=9, - NET_CORE_OPTMEM_MAX=10 + NET_CORE_OPTMEM_MAX=10, + NET_CORE_DEV_ALLOC_FAIL=11, }; /* /proc/sys/net/ethernet */ --- linux-2.2.17pre5/include/linux/skbuff.h Fri May 14 03:33:17 1999 +++ linux-akpm/include/linux/skbuff.h Sat Jun 24 14:41:45 2000 @@ -571,6 +571,7 @@ return skb; } +extern struct sk_buff *dev_alloc_skb_debug(unsigned int length); extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err); extern unsigned int datagram_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait); extern int skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size); --- linux-2.2.17pre5/net/core/skbuff.c Mon Mar 8 05:12:18 1999 +++ linux-akpm/net/core/skbuff.c Sat Jun 24 16:06:11 2000 @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,10 @@ static atomic_t net_allocs = ATOMIC_INIT(0); static atomic_t net_fails = ATOMIC_INIT(0); +#if defined(CONFIG_SYSCTL) +int dev_alloc_fail = 0; +#endif /* CONFIG_PROC_FS */ + extern atomic_t ip_frag_mem; static kmem_cache_t *skbuff_head_cache; @@ -108,6 +113,24 @@ printk("IP fragment buffer size : %u\n", atomic_read(&ip_frag_mem)); #endif +} + +struct sk_buff *dev_alloc_skb_debug(unsigned int length) +{ + struct sk_buff *skb; + +#if defined(CONFIG_SYSCTL) + if (dev_alloc_fail && length >= dev_alloc_fail) { + printk("failing a dev_alloc_skb_debug(%d)\n", length); + atomic_inc(&net_fails); + return NULL; + } +#endif /* CONFIG_PROC_FS */ + + skb = alloc_skb(length+16, GFP_ATOMIC); + if (skb) + skb_reserve(skb,16); + return skb; } /* Allocate a new skbuff. We do this ourselves so we can fill in a few --- linux-2.2.17pre5/net/netsyms.c Fri Jun 16 23:48:01 2000 +++ linux-akpm/net/netsyms.c Sat Jun 24 15:34:13 2000 @@ -476,6 +476,7 @@ #endif /* CONFIG_FDDI */ EXPORT_SYMBOL(eth_copy_and_sum); EXPORT_SYMBOL(alloc_skb); +EXPORT_SYMBOL(dev_alloc_skb_debug); EXPORT_SYMBOL(__kfree_skb); EXPORT_SYMBOL(skb_clone); EXPORT_SYMBOL(skb_copy);