xref: /openbmc/linux/include/net/netns/conntrack.h (revision 7ce05074)
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 	u8 tcp_ignore_invalid_rst;
31 #if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
32 	unsigned int offload_timeout;
33 	unsigned int offload_pickup;
34 #endif
35 };
36 
37 enum udp_conntrack {
38 	UDP_CT_UNREPLIED,
39 	UDP_CT_REPLIED,
40 	UDP_CT_MAX
41 };
42 
43 struct nf_udp_net {
44 	unsigned int timeouts[UDP_CT_MAX];
45 #if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
46 	unsigned int offload_timeout;
47 	unsigned int offload_pickup;
48 #endif
49 };
50 
51 struct nf_icmp_net {
52 	unsigned int timeout;
53 };
54 
55 #ifdef CONFIG_NF_CT_PROTO_DCCP
56 struct nf_dccp_net {
57 	u8 dccp_loose;
58 	unsigned int dccp_timeout[CT_DCCP_MAX + 1];
59 };
60 #endif
61 
62 #ifdef CONFIG_NF_CT_PROTO_SCTP
63 struct nf_sctp_net {
64 	unsigned int timeouts[SCTP_CONNTRACK_MAX];
65 };
66 #endif
67 
68 #ifdef CONFIG_NF_CT_PROTO_GRE
69 enum gre_conntrack {
70 	GRE_CT_UNREPLIED,
71 	GRE_CT_REPLIED,
72 	GRE_CT_MAX
73 };
74 
75 struct nf_gre_net {
76 	struct list_head	keymap_list;
77 	unsigned int		timeouts[GRE_CT_MAX];
78 };
79 #endif
80 
81 struct nf_ip_net {
82 	struct nf_generic_net   generic;
83 	struct nf_tcp_net	tcp;
84 	struct nf_udp_net	udp;
85 	struct nf_icmp_net	icmp;
86 	struct nf_icmp_net	icmpv6;
87 #ifdef CONFIG_NF_CT_PROTO_DCCP
88 	struct nf_dccp_net	dccp;
89 #endif
90 #ifdef CONFIG_NF_CT_PROTO_SCTP
91 	struct nf_sctp_net	sctp;
92 #endif
93 #ifdef CONFIG_NF_CT_PROTO_GRE
94 	struct nf_gre_net	gre;
95 #endif
96 };
97 
98 struct ct_pcpu {
99 	spinlock_t		lock;
100 	struct hlist_nulls_head unconfirmed;
101 	struct hlist_nulls_head dying;
102 };
103 
104 struct netns_ct {
105 #ifdef CONFIG_NF_CONNTRACK_EVENTS
106 	bool ecache_dwork_pending;
107 #endif
108 	u8			sysctl_log_invalid; /* Log invalid packets */
109 	u8			sysctl_events;
110 	u8			sysctl_acct;
111 	u8			sysctl_auto_assign_helper;
112 	u8			sysctl_tstamp;
113 	u8			sysctl_checksum;
114 
115 	struct ct_pcpu __percpu *pcpu_lists;
116 	struct ip_conntrack_stat __percpu *stat;
117 	struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
118 	struct nf_exp_event_notifier __rcu *nf_expect_event_cb;
119 	struct nf_ip_net	nf_ct_proto;
120 #if defined(CONFIG_NF_CONNTRACK_LABELS)
121 	unsigned int		labels_used;
122 #endif
123 };
124 #endif
125