This source file includes following definitions.
- __printf
- __printf
- nf_generic_pernet
- nf_tcp_pernet
- nf_udp_pernet
- nf_icmp_pernet
- nf_icmpv6_pernet
- nf_dccp_pernet
- nf_sctp_pernet
- nf_gre_pernet
1
2
3
4
5
6
7
8
9
10
11 #ifndef _NF_CONNTRACK_L4PROTO_H
12 #define _NF_CONNTRACK_L4PROTO_H
13 #include <linux/netlink.h>
14 #include <net/netlink.h>
15 #include <net/netfilter/nf_conntrack.h>
16 #include <net/netns/generic.h>
17
18 struct seq_file;
19
20 struct nf_conntrack_l4proto {
21
22 u_int8_t l4proto;
23
24
25 bool allow_clash;
26
27
28 u16 nlattr_size;
29
30
31 bool (*can_early_drop)(const struct nf_conn *ct);
32
33
34 int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla,
35 struct nf_conn *ct);
36
37
38 int (*from_nlattr)(struct nlattr *tb[], struct nf_conn *ct);
39
40 int (*tuple_to_nlattr)(struct sk_buff *skb,
41 const struct nf_conntrack_tuple *t);
42
43 unsigned int (*nlattr_tuple_size)(void);
44 int (*nlattr_to_tuple)(struct nlattr *tb[],
45 struct nf_conntrack_tuple *t);
46 const struct nla_policy *nla_policy;
47
48 struct {
49 int (*nlattr_to_obj)(struct nlattr *tb[],
50 struct net *net, void *data);
51 int (*obj_to_nlattr)(struct sk_buff *skb, const void *data);
52
53 u16 obj_size;
54 u16 nlattr_max;
55 const struct nla_policy *nla_policy;
56 } ctnl_timeout;
57 #ifdef CONFIG_NF_CONNTRACK_PROCFS
58
59 void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
60 #endif
61 };
62
63 bool icmp_pkt_to_tuple(const struct sk_buff *skb,
64 unsigned int dataoff,
65 struct net *net,
66 struct nf_conntrack_tuple *tuple);
67
68 bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
69 unsigned int dataoff,
70 struct net *net,
71 struct nf_conntrack_tuple *tuple);
72
73 bool nf_conntrack_invert_icmp_tuple(struct nf_conntrack_tuple *tuple,
74 const struct nf_conntrack_tuple *orig);
75 bool nf_conntrack_invert_icmpv6_tuple(struct nf_conntrack_tuple *tuple,
76 const struct nf_conntrack_tuple *orig);
77
78 int nf_conntrack_inet_error(struct nf_conn *tmpl, struct sk_buff *skb,
79 unsigned int dataoff,
80 const struct nf_hook_state *state,
81 u8 l4proto,
82 union nf_inet_addr *outer_daddr);
83
84 int nf_conntrack_icmpv4_error(struct nf_conn *tmpl,
85 struct sk_buff *skb,
86 unsigned int dataoff,
87 const struct nf_hook_state *state);
88
89 int nf_conntrack_icmpv6_error(struct nf_conn *tmpl,
90 struct sk_buff *skb,
91 unsigned int dataoff,
92 const struct nf_hook_state *state);
93
94 int nf_conntrack_icmp_packet(struct nf_conn *ct,
95 struct sk_buff *skb,
96 enum ip_conntrack_info ctinfo,
97 const struct nf_hook_state *state);
98
99 int nf_conntrack_icmpv6_packet(struct nf_conn *ct,
100 struct sk_buff *skb,
101 enum ip_conntrack_info ctinfo,
102 const struct nf_hook_state *state);
103
104 int nf_conntrack_udp_packet(struct nf_conn *ct,
105 struct sk_buff *skb,
106 unsigned int dataoff,
107 enum ip_conntrack_info ctinfo,
108 const struct nf_hook_state *state);
109 int nf_conntrack_udplite_packet(struct nf_conn *ct,
110 struct sk_buff *skb,
111 unsigned int dataoff,
112 enum ip_conntrack_info ctinfo,
113 const struct nf_hook_state *state);
114 int nf_conntrack_tcp_packet(struct nf_conn *ct,
115 struct sk_buff *skb,
116 unsigned int dataoff,
117 enum ip_conntrack_info ctinfo,
118 const struct nf_hook_state *state);
119 int nf_conntrack_dccp_packet(struct nf_conn *ct,
120 struct sk_buff *skb,
121 unsigned int dataoff,
122 enum ip_conntrack_info ctinfo,
123 const struct nf_hook_state *state);
124 int nf_conntrack_sctp_packet(struct nf_conn *ct,
125 struct sk_buff *skb,
126 unsigned int dataoff,
127 enum ip_conntrack_info ctinfo,
128 const struct nf_hook_state *state);
129 int nf_conntrack_gre_packet(struct nf_conn *ct,
130 struct sk_buff *skb,
131 unsigned int dataoff,
132 enum ip_conntrack_info ctinfo,
133 const struct nf_hook_state *state);
134
135 void nf_conntrack_generic_init_net(struct net *net);
136 void nf_conntrack_tcp_init_net(struct net *net);
137 void nf_conntrack_udp_init_net(struct net *net);
138 void nf_conntrack_gre_init_net(struct net *net);
139 void nf_conntrack_dccp_init_net(struct net *net);
140 void nf_conntrack_sctp_init_net(struct net *net);
141 void nf_conntrack_icmp_init_net(struct net *net);
142 void nf_conntrack_icmpv6_init_net(struct net *net);
143
144
145 extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic;
146
147 #define MAX_NF_CT_PROTO IPPROTO_UDPLITE
148
149 const struct nf_conntrack_l4proto *nf_ct_l4proto_find(u8 l4proto);
150
151
152 int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
153 const struct nf_conntrack_tuple *tuple);
154 int nf_ct_port_nlattr_to_tuple(struct nlattr *tb[],
155 struct nf_conntrack_tuple *t);
156 unsigned int nf_ct_port_nlattr_tuple_size(void);
157 extern const struct nla_policy nf_ct_port_nla_policy[];
158
159 #ifdef CONFIG_SYSCTL
160 __printf(3, 4) __cold
161 void nf_ct_l4proto_log_invalid(const struct sk_buff *skb,
162 const struct nf_conn *ct,
163 const char *fmt, ...);
164 __printf(5, 6) __cold
165 void nf_l4proto_log_invalid(const struct sk_buff *skb,
166 struct net *net,
167 u16 pf, u8 protonum,
168 const char *fmt, ...);
169 #else
170 static inline __printf(5, 6) __cold
171 void nf_l4proto_log_invalid(const struct sk_buff *skb, struct net *net,
172 u16 pf, u8 protonum, const char *fmt, ...) {}
173 static inline __printf(3, 4) __cold
174 void nf_ct_l4proto_log_invalid(const struct sk_buff *skb,
175 const struct nf_conn *ct,
176 const char *fmt, ...) { }
177 #endif
178
179 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
180 static inline struct nf_generic_net *nf_generic_pernet(struct net *net)
181 {
182 return &net->ct.nf_ct_proto.generic;
183 }
184
185 static inline struct nf_tcp_net *nf_tcp_pernet(struct net *net)
186 {
187 return &net->ct.nf_ct_proto.tcp;
188 }
189
190 static inline struct nf_udp_net *nf_udp_pernet(struct net *net)
191 {
192 return &net->ct.nf_ct_proto.udp;
193 }
194
195 static inline struct nf_icmp_net *nf_icmp_pernet(struct net *net)
196 {
197 return &net->ct.nf_ct_proto.icmp;
198 }
199
200 static inline struct nf_icmp_net *nf_icmpv6_pernet(struct net *net)
201 {
202 return &net->ct.nf_ct_proto.icmpv6;
203 }
204 #endif
205
206 #ifdef CONFIG_NF_CT_PROTO_DCCP
207 static inline struct nf_dccp_net *nf_dccp_pernet(struct net *net)
208 {
209 return &net->ct.nf_ct_proto.dccp;
210 }
211 #endif
212
213 #ifdef CONFIG_NF_CT_PROTO_SCTP
214 static inline struct nf_sctp_net *nf_sctp_pernet(struct net *net)
215 {
216 return &net->ct.nf_ct_proto.sctp;
217 }
218 #endif
219
220 #ifdef CONFIG_NF_CT_PROTO_GRE
221 static inline struct nf_gre_net *nf_gre_pernet(struct net *net)
222 {
223 return &net->ct.nf_ct_proto.gre;
224 }
225 #endif
226
227 #endif