1 /* IPv6-specific defines for netfilter.
2 * (C)1998 Rusty Russell -- This code is GPL.
3 * (C)1999 David Jeffery
4 * this header was blatantly ripped from netfilter_ipv4.h
5 * it's amazing what adding a bunch of 6s can do =8^)
7 #ifndef __LINUX_IP6_NETFILTER_H
8 #define __LINUX_IP6_NETFILTER_H
10 #include <uapi/linux/netfilter_ipv6.h>
13 /* Extra routing may needed on local out, as the QUEUE target never returns
14 * control to the table.
17 struct in6_addr daddr;
18 struct in6_addr saddr;
22 struct nf_queue_entry;
23 struct nf_ct_bridge_frag_data;
26 * Hook functions for ipv6 to allow xt_* modules to be built-in even
27 * if IPv6 is a module.
30 #if IS_MODULE(CONFIG_IPV6)
31 int (*chk_addr)(struct net *net, const struct in6_addr *addr,
32 const struct net_device *dev, int strict);
33 int (*route_me_harder)(struct net *net, struct sk_buff *skb);
34 int (*dev_get_saddr)(struct net *net, const struct net_device *dev,
35 const struct in6_addr *daddr, unsigned int srcprefs,
36 struct in6_addr *saddr);
37 int (*route)(struct net *net, struct dst_entry **dst, struct flowi *fl,
39 u32 (*cookie_init_sequence)(const struct ipv6hdr *iph,
40 const struct tcphdr *th, u16 *mssp);
41 int (*cookie_v6_check)(const struct ipv6hdr *iph,
42 const struct tcphdr *th, __u32 cookie);
44 void (*route_input)(struct sk_buff *skb);
45 int (*fragment)(struct net *net, struct sock *sk, struct sk_buff *skb,
46 int (*output)(struct net *, struct sock *, struct sk_buff *));
47 int (*reroute)(struct sk_buff *skb, const struct nf_queue_entry *entry);
48 #if IS_MODULE(CONFIG_IPV6)
49 int (*br_defrag)(struct net *net, struct sk_buff *skb, u32 user);
50 int (*br_fragment)(struct net *net, struct sock *sk,
52 struct nf_ct_bridge_frag_data *data,
53 int (*output)(struct net *, struct sock *sk,
54 const struct nf_ct_bridge_frag_data *data,
59 #ifdef CONFIG_NETFILTER
60 #include <net/addrconf.h>
62 extern const struct nf_ipv6_ops __rcu *nf_ipv6_ops;
63 static inline const struct nf_ipv6_ops *nf_get_ipv6_ops(void)
65 return rcu_dereference(nf_ipv6_ops);
68 static inline int nf_ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
69 const struct net_device *dev, int strict)
71 #if IS_MODULE(CONFIG_IPV6)
72 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
77 return v6_ops->chk_addr(net, addr, dev, strict);
78 #elif IS_BUILTIN(CONFIG_IPV6)
79 return ipv6_chk_addr(net, addr, dev, strict);
85 int __nf_ip6_route(struct net *net, struct dst_entry **dst,
86 struct flowi *fl, bool strict);
88 static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
89 struct flowi *fl, bool strict)
91 #if IS_MODULE(CONFIG_IPV6)
92 const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops();
95 return v6ops->route(net, dst, fl, strict);
99 #if IS_BUILTIN(CONFIG_IPV6)
100 return __nf_ip6_route(net, dst, fl, strict);
102 return -EHOSTUNREACH;
106 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
108 static inline int nf_ipv6_br_defrag(struct net *net, struct sk_buff *skb,
111 #if IS_MODULE(CONFIG_IPV6)
112 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
117 return v6_ops->br_defrag(net, skb, user);
118 #elif IS_BUILTIN(CONFIG_IPV6)
119 return nf_ct_frag6_gather(net, skb, user);
125 int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
126 struct nf_ct_bridge_frag_data *data,
127 int (*output)(struct net *, struct sock *sk,
128 const struct nf_ct_bridge_frag_data *data,
131 static inline int nf_br_ip6_fragment(struct net *net, struct sock *sk,
133 struct nf_ct_bridge_frag_data *data,
134 int (*output)(struct net *, struct sock *sk,
135 const struct nf_ct_bridge_frag_data *data,
138 #if IS_MODULE(CONFIG_IPV6)
139 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
144 return v6_ops->br_fragment(net, sk, skb, data, output);
145 #elif IS_BUILTIN(CONFIG_IPV6)
146 return br_ip6_fragment(net, sk, skb, data, output);
152 int ip6_route_me_harder(struct net *net, struct sk_buff *skb);
154 static inline int nf_ip6_route_me_harder(struct net *net, struct sk_buff *skb)
156 #if IS_MODULE(CONFIG_IPV6)
157 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
160 return -EHOSTUNREACH;
162 return v6_ops->route_me_harder(net, skb);
163 #elif IS_BUILTIN(CONFIG_IPV6)
164 return ip6_route_me_harder(net, skb);
166 return -EHOSTUNREACH;
170 static inline u32 nf_ipv6_cookie_init_sequence(const struct ipv6hdr *iph,
171 const struct tcphdr *th,
174 #if IS_ENABLED(CONFIG_SYN_COOKIES)
175 #if IS_MODULE(CONFIG_IPV6)
176 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
179 return v6_ops->cookie_init_sequence(iph, th, mssp);
180 #elif IS_BUILTIN(CONFIG_IPV6)
181 return __cookie_v6_init_sequence(iph, th, mssp);
187 static inline int nf_cookie_v6_check(const struct ipv6hdr *iph,
188 const struct tcphdr *th, __u32 cookie)
190 #if IS_ENABLED(CONFIG_SYN_COOKIES)
191 #if IS_MODULE(CONFIG_IPV6)
192 const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
195 return v6_ops->cookie_v6_check(iph, th, cookie);
196 #elif IS_BUILTIN(CONFIG_IPV6)
197 return __cookie_v6_check(iph, th, cookie);
203 __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
204 unsigned int dataoff, u_int8_t protocol);
206 int ipv6_netfilter_init(void);
207 void ipv6_netfilter_fini(void);
209 #else /* CONFIG_NETFILTER */
210 static inline int ipv6_netfilter_init(void) { return 0; }
211 static inline void ipv6_netfilter_fini(void) { return; }
212 static inline const struct nf_ipv6_ops *nf_get_ipv6_ops(void) { return NULL; }
213 #endif /* CONFIG_NETFILTER */
215 #endif /*__LINUX_IP6_NETFILTER_H*/