dst.c

来自「一个基于linux的TCP/IP协议栈的实现」· C语言 代码 · 共 50 行

C
50
字号
/* dst.c * linqianghe@163.com * 2006-11-13 */#include "dst.h"#if RT_CACHE_DEBUG >= 2 static atomic_t		mydst_total = ATOMIC_INIT(0);#endifstatic int mydst_discard_in(struct sk_buff *skb){	kfree_skb(skb);	return 0;}static int mydst_discard_out(struct sk_buff *skb){	kfree_skb(skb);	return 0;}void * mydst_alloc( struct dst_ops * ops ){	struct dst_entry * dst;	if( ops->gc && atomic_read(&ops->entries) > ops->gc_thresh ){		if( ops->gc() )			return NULL;	}	dst = kmem_cache_alloc( ops->kmem_cachep, SLAB_ATOMIC );	if( !dst )		return NULL;	memset( dst, 0, ops->entry_size );	atomic_set(&dst->__refcnt, 0);	dst->ops = ops;	dst->lastuse = jiffies;	dst->path = dst;	dst->input = mydst_discard_in;	dst->output = mydst_discard_out;#if RT_CACHE_DEBUG >= 2 	atomic_inc( &mydst_total );#endif	atomic_inc( &ops->entries );	return dst;}EXPORT_SYMBOL_GPL( mydst_alloc );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?