403 Star 1.4K Fork 1.3K

GVPopenEuler / kernel

 / 详情

[OLK-5.10] 添加bond驱动vendor hook

已完成
任务
创建于  
2022-02-23 10:39

添加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函数实现自己的逻辑

评论 (2)

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 , @成坚 (CHENG Jian) , @Qiuuuuu , @zhengzengkai , @gogooo , @Xie XiuQi

weiyj 创建了任务
openeuler-ci-bot 添加了
 
sig/Kernel
标签
展开全部操作日志

测试模块代码如下:

#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

正常输出:
输入图片说明

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel

搜索帮助

344bd9b3 5694891 D2dac590 5694891