Commit | Line | Data |
---|---|---|
09c434b8 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
7c23b629 PNA |
2 | #include <linux/kernel.h> |
3 | #include <linux/init.h> | |
4 | #include <linux/module.h> | |
5 | #include <linux/netfilter.h> | |
6 | #include <linux/rhashtable.h> | |
7 | #include <net/netfilter/nf_flow_table.h> | |
8 | #include <net/netfilter/nf_tables.h> | |
9 | ||
10 | static unsigned int | |
11 | nf_flow_offload_inet_hook(void *priv, struct sk_buff *skb, | |
12 | const struct nf_hook_state *state) | |
13 | { | |
14 | switch (skb->protocol) { | |
15 | case htons(ETH_P_IP): | |
16 | return nf_flow_offload_ip_hook(priv, skb, state); | |
17 | case htons(ETH_P_IPV6): | |
18 | return nf_flow_offload_ipv6_hook(priv, skb, state); | |
19 | } | |
20 | ||
21 | return NF_ACCEPT; | |
22 | } | |
23 | ||
24 | static struct nf_flowtable_type flowtable_inet = { | |
25 | .family = NFPROTO_INET, | |
a268de77 | 26 | .init = nf_flow_table_init, |
b408c5b0 | 27 | .free = nf_flow_table_free, |
7c23b629 PNA |
28 | .hook = nf_flow_offload_inet_hook, |
29 | .owner = THIS_MODULE, | |
30 | }; | |
31 | ||
32 | static int __init nf_flow_inet_module_init(void) | |
33 | { | |
34 | nft_register_flowtable_type(&flowtable_inet); | |
35 | ||
36 | return 0; | |
37 | } | |
38 | ||
39 | static void __exit nf_flow_inet_module_exit(void) | |
40 | { | |
41 | nft_unregister_flowtable_type(&flowtable_inet); | |
42 | } | |
43 | ||
44 | module_init(nf_flow_inet_module_init); | |
45 | module_exit(nf_flow_inet_module_exit); | |
46 | ||
47 | MODULE_LICENSE("GPL"); | |
48 | MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>"); | |
49 | MODULE_ALIAS_NF_FLOWTABLE(1); /* NFPROTO_INET */ |