blob: 806454e767bf422893a523eebf96b67d38a532cb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Alexey Dobriyandfdb8d72008-10-08 11:35:02 +02002#ifndef __NETNS_CONNTRACK_H
3#define __NETNS_CONNTRACK_H
4
Alexey Dobriyan63c9a262008-10-08 11:35:04 +02005#include <linux/list.h>
Eric Dumazetea781f12009-03-25 21:05:46 +01006#include <linux/list_nulls.h>
Arun Sharma600634972011-07-26 16:09:06 -07007#include <linux/atomic.h>
Florian Westphal95005072014-06-10 23:12:56 +02008#include <linux/workqueue.h>
Gao fengd2ba1fde2012-05-28 21:04:12 +00009#include <linux/netfilter/nf_conntrack_tcp.h>
Davide Carattic51d3902016-11-15 15:08:25 +010010#ifdef CONFIG_NF_CT_PROTO_DCCP
11#include <linux/netfilter/nf_conntrack_dccp.h>
12#endif
Davide Carattia85406a2016-11-15 15:08:26 +010013#ifdef CONFIG_NF_CT_PROTO_SCTP
14#include <linux/netfilter/nf_conntrack_sctp.h>
15#endif
Jesper Dangaard Brouer93bb0ce2014-03-03 14:46:13 +010016#include <linux/seqlock.h>
Alexey Dobriyan49ac8712008-10-08 11:35:03 +020017
Alexey Dobriyan80250702008-10-08 11:35:08 +020018struct ctl_table_header;
Alexey Dobriyan6058fa62008-10-08 11:35:07 +020019struct nf_conntrack_ecache;
20
Gao feng15f585b2012-05-28 21:04:11 +000021struct nf_generic_net {
Gao feng15f585b2012-05-28 21:04:11 +000022 unsigned int timeout;
23};
24
Gao fengd2ba1fde2012-05-28 21:04:12 +000025struct nf_tcp_net {
Gao fengd2ba1fde2012-05-28 21:04:12 +000026 unsigned int timeouts[TCP_CONNTRACK_TIMEOUT_MAX];
Tonghao Zhang8f14c992019-04-07 08:14:20 -070027 int tcp_loose;
28 int tcp_be_liberal;
29 int tcp_max_retrans;
Gao fengd2ba1fde2012-05-28 21:04:12 +000030};
31
Gao feng0ce490a2012-05-28 21:04:13 +000032enum udp_conntrack {
33 UDP_CT_UNREPLIED,
34 UDP_CT_REPLIED,
35 UDP_CT_MAX
36};
37
38struct nf_udp_net {
Gao feng0ce490a2012-05-28 21:04:13 +000039 unsigned int timeouts[UDP_CT_MAX];
40};
41
Gao feng4b626b92012-05-28 21:04:14 +000042struct nf_icmp_net {
Gao feng4b626b92012-05-28 21:04:14 +000043 unsigned int timeout;
44};
45
Davide Carattic51d3902016-11-15 15:08:25 +010046#ifdef CONFIG_NF_CT_PROTO_DCCP
47struct nf_dccp_net {
Davide Carattic51d3902016-11-15 15:08:25 +010048 int dccp_loose;
49 unsigned int dccp_timeout[CT_DCCP_MAX + 1];
50};
51#endif
52
Davide Carattia85406a2016-11-15 15:08:26 +010053#ifdef CONFIG_NF_CT_PROTO_SCTP
54struct nf_sctp_net {
Davide Carattia85406a2016-11-15 15:08:26 +010055 unsigned int timeouts[SCTP_CONNTRACK_MAX];
56};
57#endif
58
Florian Westphal22fc4c42019-01-15 22:03:35 +010059#ifdef CONFIG_NF_CT_PROTO_GRE
60enum gre_conntrack {
61 GRE_CT_UNREPLIED,
62 GRE_CT_REPLIED,
63 GRE_CT_MAX
64};
65
66struct nf_gre_net {
Florian Westphal22fc4c42019-01-15 22:03:35 +010067 struct list_head keymap_list;
68 unsigned int timeouts[GRE_CT_MAX];
69};
70#endif
71
Gao feng524a53e2012-05-28 21:04:10 +000072struct nf_ip_net {
Gao feng15f585b2012-05-28 21:04:11 +000073 struct nf_generic_net generic;
Gao fengd2ba1fde2012-05-28 21:04:12 +000074 struct nf_tcp_net tcp;
Gao feng0ce490a2012-05-28 21:04:13 +000075 struct nf_udp_net udp;
Gao feng4b626b92012-05-28 21:04:14 +000076 struct nf_icmp_net icmp;
Gao feng7080ba02012-05-28 21:04:15 +000077 struct nf_icmp_net icmpv6;
Davide Carattic51d3902016-11-15 15:08:25 +010078#ifdef CONFIG_NF_CT_PROTO_DCCP
79 struct nf_dccp_net dccp;
80#endif
Davide Carattia85406a2016-11-15 15:08:26 +010081#ifdef CONFIG_NF_CT_PROTO_SCTP
82 struct nf_sctp_net sctp;
83#endif
Florian Westphal22fc4c42019-01-15 22:03:35 +010084#ifdef CONFIG_NF_CT_PROTO_GRE
85 struct nf_gre_net gre;
86#endif
Gao feng524a53e2012-05-28 21:04:10 +000087};
88
Jesper Dangaard Brouerb7779d02014-03-03 14:45:20 +010089struct ct_pcpu {
90 spinlock_t lock;
91 struct hlist_nulls_head unconfirmed;
92 struct hlist_nulls_head dying;
Jesper Dangaard Brouerb7779d02014-03-03 14:45:20 +010093};
94
Alexey Dobriyandfdb8d72008-10-08 11:35:02 +020095struct netns_ct {
Alexey Dobriyan49ac8712008-10-08 11:35:03 +020096 atomic_t count;
Alexey Dobriyan9b03f382008-10-08 11:35:03 +020097 unsigned int expect_count;
Florian Westphal95005072014-06-10 23:12:56 +020098#ifdef CONFIG_NF_CONNTRACK_EVENTS
99 struct delayed_work ecache_dwork;
100 bool ecache_dwork_pending;
101#endif
Florian Westphal8527f9d2018-12-18 23:04:50 +0100102 bool auto_assign_helper_warned;
Jesper Dangaard Brouer8cf4d6a2013-11-15 15:57:53 +0100103#ifdef CONFIG_SYSCTL
104 struct ctl_table_header *sysctl_header;
Jesper Dangaard Brouer8cf4d6a2013-11-15 15:57:53 +0100105#endif
Jesper Dangaard Brouer8cf4d6a2013-11-15 15:57:53 +0100106 unsigned int sysctl_log_invalid; /* Log invalid packets */
Jesper Dangaard Brouer8cf4d6a2013-11-15 15:57:53 +0100107 int sysctl_events;
108 int sysctl_acct;
109 int sysctl_auto_assign_helper;
Jesper Dangaard Brouer8cf4d6a2013-11-15 15:57:53 +0100110 int sysctl_tstamp;
111 int sysctl_checksum;
112
Jesper Dangaard Brouerb7779d02014-03-03 14:45:20 +0100113 struct ct_pcpu __percpu *pcpu_lists;
Tejun Heo7d720c32010-02-16 15:20:26 +0000114 struct ip_conntrack_stat __percpu *stat;
Pablo Neira Ayuso70e99422011-11-22 00:16:51 +0100115 struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
116 struct nf_exp_event_notifier __rcu *nf_expect_event_cb;
Gao feng524a53e2012-05-28 21:04:10 +0000117 struct nf_ip_net nf_ct_proto;
Florian Westphalc539f012013-01-11 06:30:44 +0000118#if defined(CONFIG_NF_CONNTRACK_LABELS)
119 unsigned int labels_used;
Florian Westphalc539f012013-01-11 06:30:44 +0000120#endif
Alexey Dobriyandfdb8d72008-10-08 11:35:02 +0200121};
122#endif