xref: /openbmc/linux/include/net/netns/conntrack.h (revision 8dda2eac)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NETNS_CONNTRACK_H
3 #define __NETNS_CONNTRACK_H
4 
5 #include <linux/list.h>
6 #include <linux/list_nulls.h>
7 #include <linux/atomic.h>
8 #include <linux/workqueue.h>
9 #include <linux/netfilter/nf_conntrack_tcp.h>
10 #ifdef CONFIG_NF_CT_PROTO_DCCP
11 #include <linux/netfilter/nf_conntrack_dccp.h>
12 #endif
13 #ifdef CONFIG_NF_CT_PROTO_SCTP
14 #include <linux/netfilter/nf_conntrack_sctp.h>
15 #endif
16 #include <linux/seqlock.h>
17 
18 struct ctl_table_header;
19 struct nf_conntrack_ecache;
20 
21 struct nf_generic_net {
22 	unsigned int timeout;
23 };
24 
25 struct nf_tcp_net {
26 	unsigned int timeouts[TCP_CONNTRACK_TIMEOUT_MAX];
27 	u8 tcp_loose;
28 	u8 tcp_be_liberal;
29 	u8 tcp_max_retrans;
30 #if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
31 	unsigned int offload_timeout;
32 	unsigned int offload_pickup;
33 #endif
34 };
35 
36 enum udp_conntrack {
37 	UDP_CT_UNREPLIED,
38 	UDP_CT_REPLIED,
39 	UDP_CT_MAX
40 };
41 
42 struct nf_udp_net {
43 	unsigned int timeouts[UDP_CT_MAX];
44 #if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
45 	unsigned int offload_timeout;
46 	unsigned int offload_pickup;
47 #endif
48 };
49 
50 struct nf_icmp_net {
51 	unsigned int timeout;
52 };
53 
54 #ifdef CONFIG_NF_CT_PROTO_DCCP
55 struct nf_dccp_net {
56 	u8 dccp_loose;
57 	unsigned int dccp_timeout[CT_DCCP_MAX + 1];
58 };
59 #endif
60 
61 #ifdef CONFIG_NF_CT_PROTO_SCTP
62 struct nf_sctp_net {
63 	unsigned int timeouts[SCTP_CONNTRACK_MAX];
64 };
65 #endif
66 
67 #ifdef CONFIG_NF_CT_PROTO_GRE
68 enum gre_conntrack {
69 	GRE_CT_UNREPLIED,
70 	GRE_CT_REPLIED,
71 	GRE_CT_MAX
72 };
73 
74 struct nf_gre_net {
75 	struct list_head	keymap_list;
76 	unsigned int		timeouts[GRE_CT_MAX];
77 };
78 #endif
79 
80 struct nf_ip_net {
81 	struct nf_generic_net   generic;
82 	struct nf_tcp_net	tcp;
83 	struct nf_udp_net	udp;
84 	struct nf_icmp_net	icmp;
85 	struct nf_icmp_net	icmpv6;
86 #ifdef CONFIG_NF_CT_PROTO_DCCP
87 	struct nf_dccp_net	dccp;
88 #endif
89 #ifdef CONFIG_NF_CT_PROTO_SCTP
90 	struct nf_sctp_net	sctp;
91 #endif
92 #ifdef CONFIG_NF_CT_PROTO_GRE
93 	struct nf_gre_net	gre;
94 #endif
95 };
96 
97 struct ct_pcpu {
98 	spinlock_t		lock;
99 	struct hlist_nulls_head unconfirmed;
100 	struct hlist_nulls_head dying;
101 };
102 
103 struct netns_ct {
104 #ifdef CONFIG_NF_CONNTRACK_EVENTS
105 	bool ecache_dwork_pending;
106 #endif
107 	u8			sysctl_log_invalid; /* Log invalid packets */
108 	u8			sysctl_events;
109 	u8			sysctl_acct;
110 	u8			sysctl_auto_assign_helper;
111 	u8			sysctl_tstamp;
112 	u8			sysctl_checksum;
113 
114 	struct ct_pcpu __percpu *pcpu_lists;
115 	struct ip_conntrack_stat __percpu *stat;
116 	struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
117 	struct nf_exp_event_notifier __rcu *nf_expect_event_cb;
118 	struct nf_ip_net	nf_ct_proto;
119 #if defined(CONFIG_NF_CONNTRACK_LABELS)
120 	unsigned int		labels_used;
121 #endif
122 };
123 #endif
124