diff mbox series

[bpf-next] bpf: use kfunc hooks instead of program types

Message ID 20240820000245.61787-1-technoboy85@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] bpf: use kfunc hooks instead of program types | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-8 fail Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 fail Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-22 fail Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 fail Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-30 fail Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 fail Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 fail Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-37 fail Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-38 fail Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / veristat
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 272 this patch: 273
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 22 maintainers not CCed: andrii@kernel.org sdf@fomichev.me eddyz87@gmail.com haoluo@google.com mathieu.desnoyers@efficios.com song@kernel.org linux-stm32@st-md-mailman.stormreply.com ast@kernel.org martin.lau@linux.dev john.fastabend@gmail.com tytso@mit.edu mykolal@fb.com linux-arm-kernel@lists.infradead.org jolsa@kernel.org daniel@iogearbox.net thinker.li@gmail.com jrife@google.com yonghong.song@linux.dev jack@suse.cz hawk@kernel.org kpsingh@kernel.org ebiggers@kernel.org
netdev/build_clang fail Errors and warnings before: 340 this patch: 342
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 7032 this patch: 7033
netdev/checkpatch warning CHECK: Please don't use multiple blank lines CHECK: Please use a blank line after function/struct/union/enum declarations WARNING: line length of 83 exceeds 80 columns WARNING: line length of 84 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns WARNING: line length of 86 exceeds 80 columns WARNING: line length of 87 exceeds 80 columns WARNING: line length of 89 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns WARNING: line length of 91 exceeds 80 columns WARNING: line length of 92 exceeds 80 columns WARNING: line length of 93 exceeds 80 columns WARNING: line length of 94 exceeds 80 columns WARNING: line length of 95 exceeds 80 columns WARNING: line length of 97 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 32 this patch: 32
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc

Commit Message

Matteo Croce Aug. 20, 2024, 12:02 a.m. UTC
From: Matteo Croce <teknoraver@meta.com>

Pass to register_btf_kfunc_id_set() a btf_kfunc_hook directly, instead
of a bpf_prog_type.
Many program types share the same kfunc hook, so some calls to
register_btf_kfunc_id_set() can be removed.

Tested compiling the kernel with -Werror=enum-conversion to catch all
the occourrences.

Signed-off-by: Matteo Croce <teknoraver@meta.com>
---
 Documentation/bpf/kfuncs.rst                  |  2 +-
 drivers/hid/bpf/hid_bpf_dispatch.c            |  4 +--
 fs/bpf_fs_kfuncs.c                            |  2 +-
 fs/verity/measure.c                           |  2 +-
 include/linux/btf.h                           | 22 ++++++++++++++--
 kernel/bpf/arena.c                            |  2 +-
 kernel/bpf/btf.c                              | 23 +----------------
 kernel/bpf/cpumask.c                          |  6 ++---
 kernel/bpf/crypto.c                           |  8 +++---
 kernel/bpf/helpers.c                          | 15 +++++------
 kernel/bpf/map_iter.c                         |  2 +-
 kernel/cgroup/rstat.c                         |  2 +-
 kernel/trace/bpf_trace.c                      |  4 +--
 net/bpf/test_run.c                            |  6 ++---
 net/core/filter.c                             | 25 ++++++++-----------
 net/core/xdp.c                                |  2 +-
 net/ipv4/bpf_tcp_ca.c                         |  2 +-
 net/ipv4/fou_bpf.c                            |  2 +-
 net/ipv4/tcp_bbr.c                            |  2 +-
 net/ipv4/tcp_cubic.c                          |  2 +-
 net/ipv4/tcp_dctcp.c                          |  2 +-
 net/netfilter/nf_conntrack_bpf.c              |  4 +--
 net/netfilter/nf_flow_table_bpf.c             |  2 +-
 net/netfilter/nf_nat_bpf.c                    |  4 +--
 net/xfrm/xfrm_interface_bpf.c                 |  2 +-
 net/xfrm/xfrm_state_bpf.c                     |  2 +-
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   |  8 +++---
 27 files changed, 76 insertions(+), 83 deletions(-)

Comments

Alexei Starovoitov Aug. 20, 2024, 6:34 a.m. UTC | #1
On Tue, Aug 20, 2024 at 2:03 AM Matteo Croce <technoboy85@gmail.com> wrote:
>
> From: Matteo Croce <teknoraver@meta.com>
>
> Pass to register_btf_kfunc_id_set() a btf_kfunc_hook directly, instead
> of a bpf_prog_type.
> Many program types share the same kfunc hook, so some calls to
> register_btf_kfunc_id_set() can be removed.
>
> Tested compiling the kernel with -Werror=enum-conversion to catch all
> the occourrences.
>
> Signed-off-by: Matteo Croce <teknoraver@meta.com>

I think it's too soon to do this kind of cleanup.
We need to refactor this logic to accommodate sched-ext
allow/deny pattern for kfunc per struct-ops hook.
Let's keep this code as-is for now.
pw-bot: cr
kernel test robot Aug. 20, 2024, 6:58 a.m. UTC | #2
Hi Matteo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Matteo-Croce/bpf-use-kfunc-hooks-instead-of-program-types/20240820-080354
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20240820000245.61787-1-technoboy85%40gmail.com
patch subject: [PATCH bpf-next] bpf: use kfunc hooks instead of program types
config: arc-randconfig-002-20240820 (https://download.01.org/0day-ci/archive/20240820/202408201433.eqBpp8z9-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408201433.eqBpp8z9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408201433.eqBpp8z9-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/core/filter.c:12084:38: warning: 'bpf_kfunc_set_sock_addr' defined but not used [-Wunused-const-variable=]
   12084 | static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
         |                                      ^~~~~~~~~~~~~~~~~~~~~~~


vim +/bpf_kfunc_set_sock_addr +12084 net/core/filter.c

05421aecd4ed65 Joanne Koong  2023-03-01  12083  
53e380d2144190 Daan De Meyer 2023-10-11 @12084  static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
53e380d2144190 Daan De Meyer 2023-10-11  12085  	.owner = THIS_MODULE,
53e380d2144190 Daan De Meyer 2023-10-11  12086  	.set = &bpf_kfunc_check_set_sock_addr,
53e380d2144190 Daan De Meyer 2023-10-11  12087  };
53e380d2144190 Daan De Meyer 2023-10-11  12088
kernel test robot Aug. 20, 2024, 7:19 a.m. UTC | #3
Hi Matteo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Matteo-Croce/bpf-use-kfunc-hooks-instead-of-program-types/20240820-080354
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20240820000245.61787-1-technoboy85%40gmail.com
patch subject: [PATCH bpf-next] bpf: use kfunc hooks instead of program types
config: i386-buildonly-randconfig-001-20240820 (https://download.01.org/0day-ci/archive/20240820/202408201510.KPb6hCTA-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408201510.KPb6hCTA-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408201510.KPb6hCTA-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/core/filter.c:12084:38: warning: unused variable 'bpf_kfunc_set_sock_addr' [-Wunused-const-variable]
    12084 | static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
          |                                      ^~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.


vim +/bpf_kfunc_set_sock_addr +12084 net/core/filter.c

05421aecd4ed65 Joanne Koong  2023-03-01  12083  
53e380d2144190 Daan De Meyer 2023-10-11 @12084  static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
53e380d2144190 Daan De Meyer 2023-10-11  12085  	.owner = THIS_MODULE,
53e380d2144190 Daan De Meyer 2023-10-11  12086  	.set = &bpf_kfunc_check_set_sock_addr,
53e380d2144190 Daan De Meyer 2023-10-11  12087  };
53e380d2144190 Daan De Meyer 2023-10-11  12088
Matteo Croce Aug. 20, 2024, 8:49 a.m. UTC | #4
Il giorno mar 20 ago 2024 alle ore 08:59 kernel test robot
<lkp@intel.com> ha scritto:
>
> Hi Matteo,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on bpf-next/master]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Matteo-Croce/bpf-use-kfunc-hooks-instead-of-program-types/20240820-080354
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
> patch link:    https://lore.kernel.org/r/20240820000245.61787-1-technoboy85%40gmail.com
> patch subject: [PATCH bpf-next] bpf: use kfunc hooks instead of program types
> config: arc-randconfig-002-20240820 (https://download.01.org/0day-ci/archive/20240820/202408201433.eqBpp8z9-lkp@intel.com/config)
> compiler: arc-elf-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408201433.eqBpp8z9-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202408201433.eqBpp8z9-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> >> net/core/filter.c:12084:38: warning: 'bpf_kfunc_set_sock_addr' defined but not used [-Wunused-const-variable=]
>    12084 | static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
>          |                                      ^~~~~~~~~~~~~~~~~~~~~~~
>
>
> vim +/bpf_kfunc_set_sock_addr +12084 net/core/filter.c
>
> 05421aecd4ed65 Joanne Koong  2023-03-01  12083
> 53e380d2144190 Daan De Meyer 2023-10-11 @12084  static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
> 53e380d2144190 Daan De Meyer 2023-10-11  12085          .owner = THIS_MODULE,
> 53e380d2144190 Daan De Meyer 2023-10-11  12086          .set = &bpf_kfunc_check_set_sock_addr,
> 53e380d2144190 Daan De Meyer 2023-10-11  12087  };
> 53e380d2144190 Daan De Meyer 2023-10-11  12088
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

It seems that I removed one too many calls, the last one was using
bpf_kfunc_set_sock_addr and needs to be kept.
diff mbox series

Patch

diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
index a8f5782bd833..136c449b26d4 100644
--- a/Documentation/bpf/kfuncs.rst
+++ b/Documentation/bpf/kfuncs.rst
@@ -359,7 +359,7 @@  type. An example is shown below::
 
         static int init_subsystem(void)
         {
-                return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_task_kfunc_set);
+                return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_task_kfunc_set);
         }
         late_initcall(init_subsystem);
 
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c
index a272a086c950..37a87d70a382 100644
--- a/drivers/hid/bpf/hid_bpf_dispatch.c
+++ b/drivers/hid/bpf/hid_bpf_dispatch.c
@@ -660,13 +660,13 @@  static int __init hid_bpf_init(void)
 	 * This is not a big deal: nobody will be able to use the functionality.
 	 */
 
-	err = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &hid_bpf_kfunc_set);
+	err = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &hid_bpf_kfunc_set);
 	if (err) {
 		pr_warn("error while setting HID BPF tracing kfuncs: %d", err);
 		return 0;
 	}
 
-	err = register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &hid_bpf_syscall_kfunc_set);
+	err = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL, &hid_bpf_syscall_kfunc_set);
 	if (err) {
 		pr_warn("error while setting HID BPF syscall kfuncs: %d", err);
 		return 0;
diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index 3fe9f59ef867..2661c9a4f858 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -179,7 +179,7 @@  static const struct btf_kfunc_id_set bpf_fs_kfunc_set = {
 
 static int __init bpf_fs_kfuncs_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_LSM, &bpf_fs_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_fs_kfunc_set);
 }
 
 late_initcall(bpf_fs_kfuncs_init);
diff --git a/fs/verity/measure.c b/fs/verity/measure.c
index 175d2f1bc089..00f1a6077a77 100644
--- a/fs/verity/measure.c
+++ b/fs/verity/measure.c
@@ -181,7 +181,7 @@  static const struct btf_kfunc_id_set bpf_fsverity_set = {
 
 void __init fsverity_init_bpf(void)
 {
-	register_btf_kfunc_id_set(BPF_PROG_TYPE_LSM, &bpf_fsverity_set);
+	register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_fsverity_set);
 }
 
 #endif /* CONFIG_BPF_SYSCALL */
diff --git a/include/linux/btf.h b/include/linux/btf.h
index cffb43133c68..2da205e0f923 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -114,6 +114,24 @@  struct bpf_prog;
 
 typedef int (*btf_kfunc_filter_t)(const struct bpf_prog *prog, u32 kfunc_id);
 
+enum btf_kfunc_hook {
+	BTF_KFUNC_HOOK_COMMON,
+	BTF_KFUNC_HOOK_XDP,
+	BTF_KFUNC_HOOK_TC,
+	BTF_KFUNC_HOOK_STRUCT_OPS,
+	BTF_KFUNC_HOOK_TRACING,
+	BTF_KFUNC_HOOK_SYSCALL,
+	BTF_KFUNC_HOOK_FMODRET,
+	BTF_KFUNC_HOOK_CGROUP,
+	BTF_KFUNC_HOOK_SCHED_ACT,
+	BTF_KFUNC_HOOK_SK_SKB,
+	BTF_KFUNC_HOOK_SOCKET_FILTER,
+	BTF_KFUNC_HOOK_LWT,
+	BTF_KFUNC_HOOK_NETFILTER,
+	BTF_KFUNC_HOOK_KPROBE,
+	BTF_KFUNC_HOOK_MAX,
+};
+
 struct btf_kfunc_id_set {
 	struct module *owner;
 	struct btf_id_set8 *set;
@@ -566,7 +584,7 @@  u32 *btf_kfunc_id_set_contains(const struct btf *btf, u32 kfunc_btf_id,
 			       const struct bpf_prog *prog);
 u32 *btf_kfunc_is_modify_return(const struct btf *btf, u32 kfunc_btf_id,
 				const struct bpf_prog *prog);
-int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
+int register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
 			      const struct btf_kfunc_id_set *s);
 int register_btf_fmodret_id_set(const struct btf_kfunc_id_set *kset);
 s32 btf_find_dtor_kfunc(struct btf *btf, u32 btf_id);
@@ -620,7 +638,7 @@  static inline u32 *btf_kfunc_id_set_contains(const struct btf *btf,
 {
 	return NULL;
 }
-static inline int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
+static inline int register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
 					    const struct btf_kfunc_id_set *s)
 {
 	return 0;
diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index e52b3ad231b9..07bafb9327ec 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -576,6 +576,6 @@  static const struct btf_kfunc_id_set common_kfunc_set = {
 
 static int __init kfunc_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &common_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_COMMON, &common_kfunc_set);
 }
 late_initcall(kfunc_init);
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index b12db397303e..975c1d61aa2d 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -204,24 +204,6 @@ 
 DEFINE_IDR(btf_idr);
 DEFINE_SPINLOCK(btf_idr_lock);
 
-enum btf_kfunc_hook {
-	BTF_KFUNC_HOOK_COMMON,
-	BTF_KFUNC_HOOK_XDP,
-	BTF_KFUNC_HOOK_TC,
-	BTF_KFUNC_HOOK_STRUCT_OPS,
-	BTF_KFUNC_HOOK_TRACING,
-	BTF_KFUNC_HOOK_SYSCALL,
-	BTF_KFUNC_HOOK_FMODRET,
-	BTF_KFUNC_HOOK_CGROUP,
-	BTF_KFUNC_HOOK_SCHED_ACT,
-	BTF_KFUNC_HOOK_SK_SKB,
-	BTF_KFUNC_HOOK_SOCKET_FILTER,
-	BTF_KFUNC_HOOK_LWT,
-	BTF_KFUNC_HOOK_NETFILTER,
-	BTF_KFUNC_HOOK_KPROBE,
-	BTF_KFUNC_HOOK_MAX,
-};
-
 enum {
 	BTF_KFUNC_SET_MAX_CNT = 256,
 	BTF_DTOR_KFUNC_MAX_CNT = 256,
@@ -8389,11 +8371,9 @@  static int __register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
 }
 
 /* This function must be invoked only from initcalls/module init functions */
-int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
+int register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
 			      const struct btf_kfunc_id_set *kset)
 {
-	enum btf_kfunc_hook hook;
-
 	/* All kfuncs need to be tagged as such in BTF.
 	 * WARN() for initcall registrations that do not check errors.
 	 */
@@ -8402,7 +8382,6 @@  int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
 		return -EINVAL;
 	}
 
-	hook = bpf_prog_type_to_kfunc_hook(prog_type);
 	return __register_btf_kfunc_id_set(hook, kset);
 }
 EXPORT_SYMBOL_GPL(register_btf_kfunc_id_set);
diff --git a/kernel/bpf/cpumask.c b/kernel/bpf/cpumask.c
index 33c473d676a5..1a34689b2c3d 100644
--- a/kernel/bpf/cpumask.c
+++ b/kernel/bpf/cpumask.c
@@ -472,9 +472,9 @@  static int __init cpumask_kfunc_init(void)
 	};
 
 	ret = bpf_mem_alloc_init(&bpf_cpumask_ma, sizeof(struct bpf_cpumask), false);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &cpumask_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &cpumask_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &cpumask_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &cpumask_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &cpumask_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL, &cpumask_kfunc_set);
 	return  ret ?: register_btf_id_dtor_kfuncs(cpumask_dtors,
 						   ARRAY_SIZE(cpumask_dtors),
 						   THIS_MODULE);
diff --git a/kernel/bpf/crypto.c b/kernel/bpf/crypto.c
index 94854cd9c4cc..1010ffbffa10 100644
--- a/kernel/bpf/crypto.c
+++ b/kernel/bpf/crypto.c
@@ -380,10 +380,10 @@  static int __init crypto_kfunc_init(void)
 		},
 	};
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &crypt_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_ACT, &crypt_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &crypt_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL,
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &crypt_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SCHED_ACT, &crypt_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP, &crypt_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL,
 					       &crypt_init_kfunc_set);
 	return  ret ?: register_btf_id_dtor_kfuncs(bpf_crypto_dtors,
 						   ARRAY_SIZE(bpf_crypto_dtors),
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 12e3aa40b180..3f3b68207941 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -3070,16 +3070,17 @@  static int __init kfunc_init(void)
 #endif
 	};
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &generic_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &generic_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &generic_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &generic_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &generic_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SKB, &generic_kfunc_set);
+
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &generic_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &generic_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP, &generic_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &generic_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL, &generic_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_CGROUP, &generic_kfunc_set);
 	ret = ret ?: register_btf_id_dtor_kfuncs(generic_dtors,
 						  ARRAY_SIZE(generic_dtors),
 						  THIS_MODULE);
-	return ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &common_kfunc_set);
+	return ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_COMMON, &common_kfunc_set);
 }
 
 late_initcall(kfunc_init);
diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c
index 9575314f40a6..60f8133abd05 100644
--- a/kernel/bpf/map_iter.c
+++ b/kernel/bpf/map_iter.c
@@ -224,6 +224,6 @@  static const struct btf_kfunc_id_set bpf_map_iter_kfunc_set = {
 
 static int init_subsystem(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_map_iter_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_COMMON, &bpf_map_iter_kfunc_set);
 }
 late_initcall(init_subsystem);
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index a06b45272411..afaa9a437c1b 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -649,7 +649,7 @@  static const struct btf_kfunc_id_set bpf_rstat_kfunc_set = {
 
 static int __init bpf_rstat_kfunc_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING,
 					 &bpf_rstat_kfunc_set);
 }
 late_initcall(bpf_rstat_kfunc_init);
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index b69a39316c0c..c30264e9c3cb 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1408,7 +1408,7 @@  static const struct btf_kfunc_id_set bpf_key_sig_kfunc_set = {
 
 static int __init bpf_key_sig_kfuncs_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING,
 					 &bpf_key_sig_kfunc_set);
 }
 
@@ -3473,7 +3473,7 @@  static const struct btf_kfunc_id_set bpf_kprobe_multi_kfunc_set = {
 
 static int __init bpf_kprobe_multi_kfuncs_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_KPROBE, &bpf_kprobe_multi_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_KPROBE, &bpf_kprobe_multi_kfunc_set);
 }
 
 late_initcall(bpf_kprobe_multi_kfuncs_init);
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 6d7a442ceb89..2ce805125cb2 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -1753,9 +1753,9 @@  static int __init bpf_prog_test_run_init(void)
 	int ret;
 
 	ret = register_btf_fmodret_id_set(&bpf_test_modify_return_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_prog_test_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_prog_test_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &bpf_prog_test_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &bpf_prog_test_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_prog_test_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL, &bpf_prog_test_kfunc_set);
 	return ret ?: register_btf_id_dtor_kfuncs(bpf_prog_test_dtor_kfunc,
 						  ARRAY_SIZE(bpf_prog_test_dtor_kfunc),
 						  THIS_MODULE);
diff --git a/net/core/filter.c b/net/core/filter.c
index 78a6f746ea0b..ce764c31240c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -12095,20 +12095,15 @@  static int __init bpf_kfunc_init(void)
 {
 	int ret;
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_ACT, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SK_SKB, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SOCKET_FILTER, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SKB, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_OUT, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_IN, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_XMIT, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_SEG6LOCAL, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_NETFILTER, &bpf_kfunc_set_skb);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &bpf_kfunc_set_xdp);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
-					       &bpf_kfunc_set_sock_addr);
-	return ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_kfunc_set_tcp_reqsk);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SCHED_ACT, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SK_SKB, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SOCKET_FILTER, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_CGROUP, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_LWT, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_NETFILTER, &bpf_kfunc_set_skb);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP, &bpf_kfunc_set_xdp);
+	return ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &bpf_kfunc_set_tcp_reqsk);
 }
 late_initcall(bpf_kfunc_init);
 
@@ -12168,6 +12163,6 @@  static const struct btf_kfunc_id_set bpf_sk_iter_kfunc_set = {
 
 static int init_subsystem(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_sk_iter_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_sk_iter_kfunc_set);
 }
 late_initcall(init_subsystem);
diff --git a/net/core/xdp.c b/net/core/xdp.c
index bcc5551c6424..d602b9184686 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -797,7 +797,7 @@  bool bpf_dev_bound_kfunc_id(u32 btf_id)
 
 static int __init xdp_metadata_init(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &xdp_metadata_kfunc_set);
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP, &xdp_metadata_kfunc_set);
 }
 late_initcall(xdp_metadata_init);
 
diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
index 554804774628..a1fc378cc58c 100644
--- a/net/ipv4/bpf_tcp_ca.c
+++ b/net/ipv4/bpf_tcp_ca.c
@@ -341,7 +341,7 @@  static int __init bpf_tcp_ca_kfunc_init(void)
 {
 	int ret;
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &bpf_tcp_ca_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &bpf_tcp_ca_kfunc_set);
 	ret = ret ?: register_bpf_struct_ops(&bpf_tcp_congestion_ops, tcp_congestion_ops);
 
 	return ret;
diff --git a/net/ipv4/fou_bpf.c b/net/ipv4/fou_bpf.c
index 54984f3170a8..f9a68a20cd7c 100644
--- a/net/ipv4/fou_bpf.c
+++ b/net/ipv4/fou_bpf.c
@@ -112,6 +112,6 @@  static const struct btf_kfunc_id_set fou_bpf_kfunc_set = {
 
 int register_fou_bpf(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC,
 					 &fou_bpf_kfunc_set);
 }
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index 760941e55153..49d80dbd5f26 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -1177,7 +1177,7 @@  static int __init bbr_register(void)
 
 	BUILD_BUG_ON(sizeof(struct bbr) > ICSK_CA_PRIV_SIZE);
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &tcp_bbr_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &tcp_bbr_kfunc_set);
 	if (ret < 0)
 		return ret;
 	return tcp_register_congestion_control(&tcp_bbr_cong_ops);
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 5dbed91c6178..2ed23f429a8c 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -533,7 +533,7 @@  static int __init cubictcp_register(void)
 	/* divide by bic_scale and by constant Srtt (100ms) */
 	do_div(cube_factor, bic_scale * 10);
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &tcp_cubic_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &tcp_cubic_kfunc_set);
 	if (ret < 0)
 		return ret;
 	return tcp_register_congestion_control(&cubictcp);
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index 8a45a4aea933..b86007e9487d 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -291,7 +291,7 @@  static int __init dctcp_register(void)
 
 	BUILD_BUG_ON(sizeof(struct dctcp) > ICSK_CA_PRIV_SIZE);
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &tcp_dctcp_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_STRUCT_OPS, &tcp_dctcp_kfunc_set);
 	if (ret < 0)
 		return ret;
 	return tcp_register_congestion_control(&dctcp);
diff --git a/net/netfilter/nf_conntrack_bpf.c b/net/netfilter/nf_conntrack_bpf.c
index 4a136fc3a9c0..356559e5505f 100644
--- a/net/netfilter/nf_conntrack_bpf.c
+++ b/net/netfilter/nf_conntrack_bpf.c
@@ -531,8 +531,8 @@  int register_nf_conntrack_bpf(void)
 {
 	int ret;
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &nf_conntrack_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &nf_conntrack_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP, &nf_conntrack_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &nf_conntrack_kfunc_set);
 	if (!ret) {
 		mutex_lock(&nf_conn_btf_access_lock);
 		nfct_btf_struct_access = _nf_conntrack_btf_struct_access;
diff --git a/net/netfilter/nf_flow_table_bpf.c b/net/netfilter/nf_flow_table_bpf.c
index 4a5f5195f2d2..0166882856a2 100644
--- a/net/netfilter/nf_flow_table_bpf.c
+++ b/net/netfilter/nf_flow_table_bpf.c
@@ -115,7 +115,7 @@  static const struct btf_kfunc_id_set nf_flow_kfunc_set = {
 
 int nf_flow_register_bpf(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP,
 					 &nf_flow_kfunc_set);
 }
 EXPORT_SYMBOL_GPL(nf_flow_register_bpf);
diff --git a/net/netfilter/nf_nat_bpf.c b/net/netfilter/nf_nat_bpf.c
index 481be15609b1..a3300e3618ab 100644
--- a/net/netfilter/nf_nat_bpf.c
+++ b/net/netfilter/nf_nat_bpf.c
@@ -67,11 +67,11 @@  int register_nf_nat_bpf(void)
 {
 	int ret;
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP,
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP,
 					&nf_bpf_nat_kfunc_set);
 	if (ret)
 		return ret;
 
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC,
 					 &nf_bpf_nat_kfunc_set);
 }
diff --git a/net/xfrm/xfrm_interface_bpf.c b/net/xfrm/xfrm_interface_bpf.c
index 5ea15037ebd1..4c3149d22712 100644
--- a/net/xfrm/xfrm_interface_bpf.c
+++ b/net/xfrm/xfrm_interface_bpf.c
@@ -105,6 +105,6 @@  static const struct btf_kfunc_id_set xfrm_interface_kfunc_set = {
 
 int __init register_xfrm_interface_bpf(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC,
 					 &xfrm_interface_kfunc_set);
 }
diff --git a/net/xfrm/xfrm_state_bpf.c b/net/xfrm/xfrm_state_bpf.c
index 2248eda741f8..90a3a245c6de 100644
--- a/net/xfrm/xfrm_state_bpf.c
+++ b/net/xfrm/xfrm_state_bpf.c
@@ -129,6 +129,6 @@  static const struct btf_kfunc_id_set xfrm_state_xdp_kfunc_set = {
 
 int __init register_xfrm_state_bpf(void)
 {
-	return register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP,
+	return register_btf_kfunc_id_set(BTF_KFUNC_HOOK_XDP,
 					 &xfrm_state_xdp_kfunc_set);
 }
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index 3687a40b61c6..fbb4d739597d 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -1088,10 +1088,10 @@  static int bpf_testmod_init(void)
 	void **tramp;
 	int ret;
 
-	ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_testmod_common_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_testmod_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_testmod_kfunc_set);
-	ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &bpf_testmod_kfunc_set);
+	ret = register_btf_kfunc_id_set(BTF_KFUNC_HOOK_COMMON, &bpf_testmod_common_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TC, &bpf_testmod_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_TRACING, &bpf_testmod_kfunc_set);
+	ret = ret ?: register_btf_kfunc_id_set(BTF_KFUNC_HOOK_SYSCALL, &bpf_testmod_kfunc_set);
 	ret = ret ?: register_bpf_struct_ops(&bpf_bpf_testmod_ops, bpf_testmod_ops);
 	ret = ret ?: register_bpf_struct_ops(&bpf_testmod_ops2, bpf_testmod_ops2);
 	ret = ret ?: register_btf_id_dtor_kfuncs(bpf_testmod_dtors,