How to export symbol from Linux kernel module in this case?

后端 未结 1 1778
無奈伤痛
無奈伤痛 2020-12-22 12:38

I\'ve got two kernel modules built, one of which is a net_device. My net_device module A depends on module B which provide some extra control mechanism to export device info

相关标签:
1条回答
  • 2020-12-22 13:02

    You may provide the callback function from module A. In that case you don't need to export each function you need to the kernel namespace. I presume you just could supply some structure to the B. Something like:

    internal header:

    struct possible_ops {
        int (*xmit)(...);
    };
    

    A:

    struct private {
        struct possible_ops *ops;
    };
    ...  
    ops = kzalloc(sizeof(*ops));
    ops->xmit = xmit;
    

    B:

    whatever(struct possible_ops *ops) {
        if (ops && ops->xmit) {
            ret = ops->xmit();
            ...
        }
    }
    
    0 讨论(0)
提交回复
热议问题