学习Linux-4.12内核网路协议栈(1.3)——协议栈的初始化(sock_init)


初始化的时候,第一个调用的是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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值