【发布时间】:2022-02-03 03:56:34
【问题描述】:
我编写网卡模块驱动程序并实现它的基本功能,如ndo_open、ndo_stop、ndo_start_xmit...
在最近的版本中,有时 Linux 内核 API 会发生变化。所以像LINUX_VERSION_CODE 这样的宏有助于将模块的代码采用到最近的 Linux 内核版本中。在 CentOS(RHEL) 中,我遇到了改变 NIC 的 MTU 的函数名称与 vanilla Linux Kernel 不同。在 vanilla Linux Kernel v.3.10.0 它的原型是:
int (*ndo_change_mtu)(struct net_device *dev,
int new_mtu);
但在CentOS 7.6.1810 3.10.0-957.el7.x86_64 中却是:
RH_KABI_RENAME(int (*ndo_change_mtu),
int (*ndo_change_mtu_rh74))(struct net_device *dev,
int new_mtu);
所以我必须使用ndo_change_mtu_rh74 而不是ndo_change_mtu,它可以正常工作。
是否可以使用一些宏在不同Linux内核版本之间采用模块的代码而不用打补丁来防止针对CentOS(RHEL)Linux内核的编译错误?
【问题讨论】:
-
@omajid 这就是我需要的!请发表您的评论作为答案,我会应用它。谢谢!
标签: centos kernel-module rhel7