1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/sysctl.h>
4 #include <net/lwtunnel.h>
5 #include <net/netfilter/nf_hooks_lwtunnel.h>
7 static inline int nf_hooks_lwtunnel_get(void)
9 if (static_branch_unlikely(&nf_hooks_lwtunnel_enabled))
15 static inline int nf_hooks_lwtunnel_set(int enable)
17 if (static_branch_unlikely(&nf_hooks_lwtunnel_enabled)) {
21 static_branch_enable(&nf_hooks_lwtunnel_enabled);
28 int nf_hooks_lwtunnel_sysctl_handler(struct ctl_table *table, int write,
29 void *buffer, size_t *lenp, loff_t *ppos)
31 int proc_nf_hooks_lwtunnel_enabled = 0;
32 struct ctl_table tmp = {
33 .procname = table->procname,
34 .data = &proc_nf_hooks_lwtunnel_enabled,
35 .maxlen = sizeof(int),
37 .extra1 = SYSCTL_ZERO,
43 proc_nf_hooks_lwtunnel_enabled = nf_hooks_lwtunnel_get();
45 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
47 if (write && ret == 0)
48 ret = nf_hooks_lwtunnel_set(proc_nf_hooks_lwtunnel_enabled);
52 EXPORT_SYMBOL_GPL(nf_hooks_lwtunnel_sysctl_handler);
53 #endif /* CONFIG_SYSCTL */