初始化的时候,第一个调用的是sock_init,它主要完成:
1. sysctl文件的创建
2. skb高速缓存初始化,它会在slab创建两个节点skbuff_head_cache和skbuff_fclone_cache
3.注册并挂socket文件系统
static int __init sock_init(void)
{
int err;
/*
* Initialize the network sysctl infrastructure.
*/
err = net_sysctl_init(); //这里创建sys文件,用于管理和查看一下网络参数
if (err)
goto out;
/*
* Initialize skbuff SLAB cache
*/
skb_init(); //skb高速缓存初始化,它会在slab创建两个节点skbuff_head_cache和skbuff_fclone_cache
/*
* Initialize the protocols module.
*/
init_inodecache();
err = register_filesystem(&sock_fs_type); //注册sock文件系统
if (err)
goto out_fs;
sock_mnt = kern_mount(&sock_fs_type); //挂载sock文件系统到super_blocks
if (IS_ERR(sock_mnt)) {
err = PTR_ERR(sock_mnt);
goto out_mount;
}
/* The real protocol ini