1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NF_CONNTRACK_SYNPROXY_H
3 #define _NF_CONNTRACK_SYNPROXY_H
5 #include <net/netfilter/nf_conntrack_seqadj.h>
6 #include <net/netns/generic.h>
8 struct nf_conn_synproxy {
14 static inline struct nf_conn_synproxy *nfct_synproxy(const struct nf_conn *ct)
16 #if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
17 return nf_ct_ext_find(ct, NF_CT_EXT_SYNPROXY);
23 static inline struct nf_conn_synproxy *nfct_synproxy_ext_add(struct nf_conn *ct)
25 #if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
26 return nf_ct_ext_add(ct, NF_CT_EXT_SYNPROXY, GFP_ATOMIC);
32 static inline bool nf_ct_add_synproxy(struct nf_conn *ct,
33 const struct nf_conn *tmpl)
35 if (tmpl && nfct_synproxy(tmpl)) {
36 if (!nfct_seqadj_ext_add(ct))
39 if (!nfct_synproxy_ext_add(ct))
46 struct synproxy_stats {
47 unsigned int syn_received;
48 unsigned int cookie_invalid;
49 unsigned int cookie_valid;
50 unsigned int cookie_retrans;
51 unsigned int conn_reopened;
56 struct synproxy_stats __percpu *stats;
57 unsigned int hook_ref4;
58 unsigned int hook_ref6;
61 extern unsigned int synproxy_net_id;
62 static inline struct synproxy_net *synproxy_pernet(struct net *net)
64 return net_generic(net, synproxy_net_id);
67 struct synproxy_options {
77 struct nf_synproxy_info;
78 bool synproxy_parse_options(const struct sk_buff *skb, unsigned int doff,
79 const struct tcphdr *th,
80 struct synproxy_options *opts);
82 void synproxy_init_timestamp_cookie(const struct nf_synproxy_info *info,
83 struct synproxy_options *opts);
85 #endif /* _NF_CONNTRACK_SYNPROXY_H */