代码拉取完成,页面将自动刷新
添加bond驱动vendor hook点vendor_bond_check_dev_link,产品基于hook实现自己的fix逻辑,避免侵入式修改。
使用方式如下:
#include <trace/hooks/bonding.h>
static void vendor_foo(void *data, const struct bonding *bond,
const struct slave *slave, int *state)
{
pr_info("%s\n", __func__);
}
static int __init vendor_bond_init(void)
{
return register_trace_vendor_bond_check_dev_link(&vendor_foo, NULL);
}
static void __exit vendor_bond_exit(void)
{
unregister_trace_vendor_bond_check_dev_link(&vendor_foo, NULL);
}
module_init(vendor_bond_init);
module_exit(vendor_bond_exit);
vendor_foo函数实现自己的逻辑
Hi weiyj_lk, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @yangyingliang , @pi3orama , @gatieme , @qiuuuuu , @zhengzengkai , @gogooo , @xiexiuqi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
测试模块代码如下:
#include <linux/kernel.h>
#include <linux/module.h>
#include <net/bonding.h>
#include <trace/hooks/bonding.h>
static void vendor_bond_check_dev_link(void *data, const struct bonding *bond,
const struct slave *slave, int *state)
{
pr_info("%s\n", __func__);
}
static int __init bondingTestInit(void)
{
return register_trace_vendor_bond_check_dev_link(
&vendor_bond_check_dev_link, NULL);
}
static void __exit bondingTestExit(void)
{
printk("bonding test exit\n");
unregister_trace_vendor_bond_check_dev_link(&vendor_bond_check_dev_link, NULL);
}
/* 模块入口和出口函数 */
module_init(bondingTestInit)
module_exit(bondingTestExit)
/* 模块信息 */
MODULE_AUTHOR("Wei Yongjun <weiyongjun1@huawei.com>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("bondtest driver");
测试步骤:
modprobe bonding mode=0 miimon=100 max_bonds=2
ip link set eth0 down
echo +eth0 > /sys/class/net/bond0/bonding/slaves
ip link set eth0 up
ip link set bond0 up
modprobe bond_vendor
正常输出:
登录 后才可以发表评论