]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/netfilter/nf_conntrack_core.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / include / net / netfilter / nf_conntrack_core.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
9fb9cbb1
YK
2/*
3 * This header is used to share core functionality between the
4 * standalone connection tracking module, and the compatibility layer's use
5 * of connection tracking.
6 *
7 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
8 * - generalize L3 protocol dependent part.
9 *
10 * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h
11 */
12
13#ifndef _NF_CONNTRACK_CORE_H
14#define _NF_CONNTRACK_CORE_H
15
16#include <linux/netfilter.h>
77ab9cff 17#include <net/netfilter/nf_conntrack_l3proto.h>
605dcad6 18#include <net/netfilter/nf_conntrack_l4proto.h>
f6180121 19#include <net/netfilter/nf_conntrack_ecache.h>
9fb9cbb1
YK
20
21/* This header is used to share core functionality between the
22 standalone connection tracking module, and the compatibility layer's use
23 of connection tracking. */
4e77be46
JP
24unsigned int nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
25 struct sk_buff *skb);
26
27int nf_conntrack_init_net(struct net *net);
28void nf_conntrack_cleanup_net(struct net *net);
29void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
30
31int nf_conntrack_proto_pernet_init(struct net *net);
32void nf_conntrack_proto_pernet_fini(struct net *net);
33
34int nf_conntrack_proto_init(void);
35void nf_conntrack_proto_fini(void);
36
37int nf_conntrack_init_start(void);
38void nf_conntrack_cleanup_start(void);
39
40void nf_conntrack_init_end(void);
41void nf_conntrack_cleanup_end(void);
42
43bool nf_ct_get_tuple(const struct sk_buff *skb, unsigned int nhoff,
44 unsigned int dataoff, u_int16_t l3num, u_int8_t protonum,
a31f1adc 45 struct net *net,
4e77be46
JP
46 struct nf_conntrack_tuple *tuple,
47 const struct nf_conntrack_l3proto *l3proto,
48 const struct nf_conntrack_l4proto *l4proto);
49
50bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
51 const struct nf_conntrack_tuple *orig,
52 const struct nf_conntrack_l3proto *l3proto,
53 const struct nf_conntrack_l4proto *l4proto);
9fb9cbb1
YK
54
55/* Find a connection corresponding to a tuple. */
4e77be46 56struct nf_conntrack_tuple_hash *
308ac914
DB
57nf_conntrack_find_get(struct net *net,
58 const struct nf_conntrack_zone *zone,
5d0aa2cc 59 const struct nf_conntrack_tuple *tuple);
9fb9cbb1 60
4e77be46 61int __nf_conntrack_confirm(struct sk_buff *skb);
9fb9cbb1
YK
62
63/* Confirm a connection: returns NF_DROP if packet must be dropped. */
3db05fea 64static inline int nf_conntrack_confirm(struct sk_buff *skb)
9fb9cbb1 65{
cb9c6836 66 struct nf_conn *ct = (struct nf_conn *)skb_nfct(skb);
9fb9cbb1
YK
67 int ret = NF_ACCEPT;
68
ab8bc7ed 69 if (ct) {
fc350777 70 if (!nf_ct_is_confirmed(ct))
3db05fea 71 ret = __nf_conntrack_confirm(skb);
b1e93a68
PNA
72 if (likely(ret == NF_ACCEPT))
73 nf_ct_deliver_cached_events(ct);
9fb9cbb1
YK
74 }
75 return ret;
76}
77
824f1fbe 78void
77ab9cff 79print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
32948588
JE
80 const struct nf_conntrack_l3proto *l3proto,
81 const struct nf_conntrack_l4proto *proto);
77ab9cff 82
b16c2919
SL
83#define CONNTRACK_LOCKS 1024
84
93bb0ceb 85extern spinlock_t nf_conntrack_locks[CONNTRACK_LOCKS];
b16c2919 86void nf_conntrack_lock(spinlock_t *lock);
7e5d03bb 87
ca7433df
JDB
88extern spinlock_t nf_conntrack_expect_lock;
89
9fb9cbb1 90#endif /* _NF_CONNTRACK_CORE_H */