~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/netfilter_ipv6.h

Version: ~ [ linux-5.16-rc3 ] ~ [ linux-5.15.5 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.82 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.162 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.218 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.256 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.291 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.293 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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^)
  6  */
  7 #ifndef __LINUX_IP6_NETFILTER_H
  8 #define __LINUX_IP6_NETFILTER_H
  9 
 10 #include <uapi/linux/netfilter_ipv6.h>
 11 #include <net/tcp.h>
 12 
 13 /* Extra routing may needed on local out, as the QUEUE target never returns
 14  * control to the table.
 15  */
 16 struct ip6_rt_info {
 17         struct in6_addr daddr;
 18         struct in6_addr saddr;
 19         u_int32_t mark;
 20 };
 21 
 22 struct nf_queue_entry;
 23 struct nf_ct_bridge_frag_data;
 24 
 25 /*
 26  * Hook functions for ipv6 to allow xt_* modules to be built-in even
 27  * if IPv6 is a module.
 28  */
 29 struct nf_ipv6_ops {
 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,
 38                      bool strict);
 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);
 43 #endif
 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,
 51                            struct sk_buff *skb,
 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,
 55                                          struct sk_buff *));
 56 #endif
 57 };
 58 
 59 #ifdef CONFIG_NETFILTER
 60 #include <net/addrconf.h>
 61 
 62 extern const struct nf_ipv6_ops __rcu *nf_ipv6_ops;
 63 static inline const struct nf_ipv6_ops *nf_get_ipv6_ops(void)
 64 {
 65         return rcu_dereference(nf_ipv6_ops);
 66 }
 67 
 68 static inline int nf_ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
 69                                    const struct net_device *dev, int strict)
 70 {
 71 #if IS_MODULE(CONFIG_IPV6)
 72         const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
 73 
 74         if (!v6_ops)
 75                 return 1;
 76 
 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);
 80 #else
 81         return 1;
 82 #endif
 83 }
 84 
 85 int __nf_ip6_route(struct net *net, struct dst_entry **dst,
 86                                struct flowi *fl, bool strict);
 87 
 88 static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
 89                                struct flowi *fl, bool strict)
 90 {
 91 #if IS_MODULE(CONFIG_IPV6)
 92         const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops();
 93 
 94         if (v6ops)
 95                 return v6ops->route(net, dst, fl, strict);
 96 
 97         return -EHOSTUNREACH;
 98 #endif
 99 #if IS_BUILTIN(CONFIG_IPV6)
100         return __nf_ip6_route(net, dst, fl, strict);
101 #else
102         return -EHOSTUNREACH;
103 #endif
104 }
105 
106 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
107 
108 static inline int nf_ipv6_br_defrag(struct net *net, struct sk_buff *skb,
109                                     u32 user)
110 {
111 #if IS_MODULE(CONFIG_IPV6)
112         const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
113 
114         if (!v6_ops)
115                 return 1;
116 
117         return v6_ops->br_defrag(net, skb, user);
118 #elif IS_BUILTIN(CONFIG_IPV6)
119         return nf_ct_frag6_gather(net, skb, user);
120 #else
121         return 1;
122 #endif
123 }
124 
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,
129                                   struct sk_buff *));
130 
131 static inline int nf_br_ip6_fragment(struct net *net, struct sock *sk,
132                                      struct sk_buff *skb,
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,
136                                                    struct sk_buff *))
137 {
138 #if IS_MODULE(CONFIG_IPV6)
139         const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
140 
141         if (!v6_ops)
142                 return 1;
143 
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);
147 #else
148         return 1;
149 #endif
150 }
151 
152 int ip6_route_me_harder(struct net *net, struct sk_buff *skb);
153 
154 static inline int nf_ip6_route_me_harder(struct net *net, struct sk_buff *skb)
155 {
156 #if IS_MODULE(CONFIG_IPV6)
157         const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
158 
159         if (!v6_ops)
160                 return -EHOSTUNREACH;
161 
162         return v6_ops->route_me_harder(net, skb);
163 #elif IS_BUILTIN(CONFIG_IPV6)
164         return ip6_route_me_harder(net, skb);
165 #else
166         return -EHOSTUNREACH;
167 #endif
168 }
169 
170 static inline u32 nf_ipv6_cookie_init_sequence(const struct ipv6hdr *iph,
171                                                const struct tcphdr *th,
172                                                u16 *mssp)
173 {
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();
177 
178         if (v6_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);
182 #endif
183 #endif
184         return 0;
185 }
186 
187 static inline int nf_cookie_v6_check(const struct ipv6hdr *iph,
188                                      const struct tcphdr *th, __u32 cookie)
189 {
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();
193 
194         if (v6_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);
198 #endif
199 #endif
200         return 0;
201 }
202 
203 __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
204                         unsigned int dataoff, u_int8_t protocol);
205 
206 int ipv6_netfilter_init(void);
207 void ipv6_netfilter_fini(void);
208 
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 */
214 
215 #endif /*__LINUX_IP6_NETFILTER_H*/
216 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp