9 #include <linux/kernel.h>
10 #include <linux/netfilter.h>
14 #include <linux/wait.h>
15 #include <linux/module.h>
18 #include <linux/netdevice.h>
22 #include <linux/slab.h>
58 #if defined(CONFIG_JUMP_LABEL)
67 struct nf_hook_ops *
elem;
74 if (reg->priority < elem->priority)
77 list_add_rcu(®->list, elem->list.prev);
79 #if defined(CONFIG_JUMP_LABEL)
80 static_key_slow_inc(&nf_hooks_needed[reg->pf][reg->hooknum]);
89 list_del_rcu(®->list);
91 #if defined(CONFIG_JUMP_LABEL)
92 static_key_slow_dec(&nf_hooks_needed[reg->pf][reg->hooknum]);
103 for (i = 0; i <
n; i++) {
129 struct nf_hook_ops **elemp,
133 unsigned int verdict;
139 list_for_each_entry_continue_rcu((*elemp), head,
list) {
140 if (hook_thresh > (*elemp)->priority)
146 verdict = (*elemp)->hook(hook, skb, indev, outdev, okfn);
148 #ifdef CONFIG_NETFILTER_DEBUG
151 NFDEBUG(
"Evil return from %p(%u).\n",
152 (*elemp)->hook, hook);
173 struct nf_hook_ops *
elem;
174 unsigned int verdict;
180 elem = list_entry_rcu(&nf_hooks[pf][hook],
struct nf_hook_ops,
list);
182 verdict =
nf_iterate(&nf_hooks[pf][hook], skb, hook, indev,
183 outdev, &elem, okfn, hook_thresh);
188 ret = NF_DROP_GETERR(verdict);
191 }
else if ((verdict & NF_VERDICT_MASK) ==
NF_QUEUE) {
192 int err =
nf_queue(skb, elem, pf, hook, indev, outdev, okfn,
211 if (writable_len > skb->
len)
215 if (!skb_cloned(skb)) {
216 if (writable_len <= skb_headlen(skb))
218 }
else if (skb_clone_writable(skb, writable_len))
221 if (writable_len <= skb_headlen(skb))
224 writable_len -= skb_headlen(skb);
230 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
254 void nf_conntrack_destroy(
struct nf_conntrack *nfct)
274 #ifdef CONFIG_NF_NAT_NEEDED
279 #ifdef CONFIG_PROC_FS
288 for (h = 0; h < NF_MAX_HOOKS; h++)
289 INIT_LIST_HEAD(&nf_hooks[i][h]);
292 #ifdef CONFIG_PROC_FS
294 if (!proc_net_netfilter)
295 panic(
"cannot create netfilter proc entry");
299 panic(
"cannot initialize nf_queue");
301 panic(
"cannot initialize nf_log");