Commit b88ceab5 authored by Wei Yongjun's avatar Wei Yongjun Committed by Zheng Zengkai
Browse files

drivers: hooks: add bonding driver vendor hooks

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4UV43


CVE: NA

---------------------------

Allow vendor modules to attach bonding driver hooks. This
patch introduce vendor_bond_check_dev_link hook.

Usage:

  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);

Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: default avatarZhang Jialin <zhangjialin11@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 79246e86
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6090,6 +6090,7 @@ CONFIG_USB4=m
# Vendor Hooks
#
CONFIG_VENDOR_HOOKS=y
CONFIG_VENDOR_BOND_HOOKS=y
# end of Vendor Hooks

CONFIG_LIBNVDIMM=m
+1 −0
Original line number Diff line number Diff line
@@ -7183,6 +7183,7 @@ CONFIG_USB4=m
# Vendor Hooks
#
CONFIG_VENDOR_HOOKS=y
CONFIG_VENDOR_BOND_HOOKS=y
# end of Vendor Hooks

CONFIG_LIBNVDIMM=m
+10 −0
Original line number Diff line number Diff line
@@ -10,4 +10,14 @@ config VENDOR_HOOKS
          Allow vendor modules to attach to tracepoint "hooks" defined via
          DECLARE_HOOK or DECLARE_RESTRICTED_HOOK.

config VENDOR_BOND_HOOKS
        bool "Ethernet Bonding driver Vendor Hooks"
        depends on VENDOR_HOOKS && BONDING
        default n
        help
	  Enable ethernet bonding driver vendor hooks

          Allow vendor modules to attach bonding driver hooks defined via
          DECLARE_HOOK or DECLARE_RESTRICTED_HOOK.

endmenu
+4 −0
Original line number Diff line number Diff line
@@ -8,9 +8,13 @@

#define CREATE_TRACE_POINTS
#include <trace/hooks/vendor_hooks.h>
#include <trace/hooks/bonding.h>

/*
 * Export tracepoints that act as a bare tracehook (ie: have no trace event
 * associated with them) to allow external modules to probe them.
 */

#ifdef CONFIG_VENDOR_BOND_HOOKS
EXPORT_TRACEPOINT_SYMBOL_GPL(vendor_bond_check_dev_link);
#endif
+5 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@
#include <net/bonding.h>
#include <net/bond_3ad.h>
#include <net/bond_alb.h>
#include <trace/hooks/bonding.h>

#include "bonding_priv.h"

@@ -2415,6 +2416,10 @@ static int bond_miimon_inspect(struct bonding *bond)

		link_state = bond_check_dev_link(bond, slave->dev, 0);

#ifdef CONFIG_VENDOR_BOND_HOOKS
		trace_vendor_bond_check_dev_link(bond, slave, &link_state);
#endif

		switch (slave->link) {
		case BOND_LINK_UP:
			if (link_state)
Loading