1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NF_SYNPROXY_SHARED_H
3 #define _NF_SYNPROXY_SHARED_H
5 #include <linux/module.h>
6 #include <linux/skbuff.h>
7 #include <net/ip6_checksum.h>
8 #include <net/ip6_route.h>
11 #include <net/netfilter/nf_conntrack_seqadj.h>
12 #include <net/netfilter/nf_conntrack_synproxy.h>
14 struct synproxy_stats {
15 unsigned int syn_received;
16 unsigned int cookie_invalid;
17 unsigned int cookie_valid;
18 unsigned int cookie_retrans;
19 unsigned int conn_reopened;
24 struct synproxy_stats __percpu *stats;
25 unsigned int hook_ref4;
26 unsigned int hook_ref6;
29 extern unsigned int synproxy_net_id;
30 static inline struct synproxy_net *synproxy_pernet(struct net *net)
32 return net_generic(net, synproxy_net_id);
35 struct synproxy_options {
44 struct nf_synproxy_info;
45 bool synproxy_parse_options(const struct sk_buff *skb, unsigned int doff,
46 const struct tcphdr *th,
47 struct synproxy_options *opts);
49 void synproxy_init_timestamp_cookie(const struct nf_synproxy_info *info,
50 struct synproxy_options *opts);
52 void synproxy_send_client_synack(struct net *net, const struct sk_buff *skb,
53 const struct tcphdr *th,
54 const struct synproxy_options *opts);
56 bool synproxy_recv_client_ack(struct net *net,
57 const struct sk_buff *skb,
58 const struct tcphdr *th,
59 struct synproxy_options *opts, u32 recv_seq);
63 unsigned int ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
64 const struct nf_hook_state *nhs);
65 int nf_synproxy_ipv4_init(struct synproxy_net *snet, struct net *net);
66 void nf_synproxy_ipv4_fini(struct synproxy_net *snet, struct net *net);
68 #if IS_ENABLED(CONFIG_IPV6)
69 void synproxy_send_client_synack_ipv6(struct net *net,
70 const struct sk_buff *skb,
71 const struct tcphdr *th,
72 const struct synproxy_options *opts);
74 bool synproxy_recv_client_ack_ipv6(struct net *net, const struct sk_buff *skb,
75 const struct tcphdr *th,
76 struct synproxy_options *opts, u32 recv_seq);
78 unsigned int ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
79 const struct nf_hook_state *nhs);
80 int nf_synproxy_ipv6_init(struct synproxy_net *snet, struct net *net);
81 void nf_synproxy_ipv6_fini(struct synproxy_net *snet, struct net *net);
84 nf_synproxy_ipv6_init(struct synproxy_net *snet, struct net *net) { return 0; }
86 nf_synproxy_ipv6_fini(struct synproxy_net *snet, struct net *net) {};
87 #endif /* CONFIG_IPV6 */
89 #endif /* _NF_SYNPROXY_SHARED_H */