blob: ddf53dd1e9484db9a75e02b30cacf9fc47c7a04f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Linux INET6 implementation
3 *
4 * Authors:
5 * Pedro Roque <roque@di.fc.ul.pt>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _IP6_FIB_H
14#define _IP6_FIB_H
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/ipv6_route.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/rtnetlink.h>
18#include <linux/spinlock.h>
Ido Schimmel16ab6d72017-08-03 13:28:16 +020019#include <linux/notifier.h>
Thomas Graf86872cb2006-08-22 00:01:08 -070020#include <net/dst.h>
21#include <net/flow.h>
22#include <net/netlink.h>
David S. Millerb3419362010-11-30 12:27:11 -080023#include <net/inetpeer.h>
Ido Schimmel16ab6d72017-08-03 13:28:16 +020024#include <net/fib_notifier.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Neil Hormana33bc5c2009-07-30 18:52:15 -070026#ifdef CONFIG_IPV6_MULTIPLE_TABLES
27#define FIB6_TABLE_HASHSZ 256
28#else
29#define FIB6_TABLE_HASHSZ 1
30#endif
31
Wei Wangc757faa2017-10-06 12:06:01 -070032#define RT6_DEBUG 2
33
34#if RT6_DEBUG >= 3
35#define RT6_TRACE(x...) pr_debug(x)
36#else
37#define RT6_TRACE(x...) do { ; } while (0)
38#endif
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040struct rt6_info;
41
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000042struct fib6_config {
Thomas Graf86872cb2006-08-22 00:01:08 -070043 u32 fc_table;
44 u32 fc_metric;
45 int fc_dst_len;
46 int fc_src_len;
47 int fc_ifindex;
48 u32 fc_flags;
49 u32 fc_protocol;
David Ahern0ae81332017-02-02 12:37:08 -080050 u16 fc_type; /* only 8 bits are used */
51 u16 fc_delete_all_nh : 1,
52 __unused : 15;
Thomas Graf86872cb2006-08-22 00:01:08 -070053
54 struct in6_addr fc_dst;
55 struct in6_addr fc_src;
Daniel Walterc3968a82011-04-13 21:10:57 +000056 struct in6_addr fc_prefsrc;
Thomas Graf86872cb2006-08-22 00:01:08 -070057 struct in6_addr fc_gateway;
58
59 unsigned long fc_expires;
60 struct nlattr *fc_mx;
61 int fc_mx_len;
Nicolas Dichtel51ebd312012-10-22 03:42:09 +000062 int fc_mp_len;
63 struct nlattr *fc_mp;
Thomas Graf86872cb2006-08-22 00:01:08 -070064
65 struct nl_info fc_nlinfo;
Roopa Prabhu19e42e42015-07-21 10:43:48 +020066 struct nlattr *fc_encap;
67 u16 fc_encap_type;
Thomas Graf86872cb2006-08-22 00:01:08 -070068};
69
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000070struct fib6_node {
Wei Wang66f5d6c2017-10-06 12:06:10 -070071 struct fib6_node __rcu *parent;
72 struct fib6_node __rcu *left;
73 struct fib6_node __rcu *right;
Kim Nordlund8bce65b2006-12-13 16:38:29 -080074#ifdef CONFIG_IPV6_SUBTREES
Wei Wang66f5d6c2017-10-06 12:06:10 -070075 struct fib6_node __rcu *subtree;
Kim Nordlund8bce65b2006-12-13 16:38:29 -080076#endif
Wei Wang66f5d6c2017-10-06 12:06:10 -070077 struct rt6_info __rcu *leaf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 __u16 fn_bit; /* bit key */
80 __u16 fn_flags;
Hannes Frederic Sowa42b18702014-10-06 19:58:35 +020081 int fn_sernum;
Wei Wang66f5d6c2017-10-06 12:06:10 -070082 struct rt6_info __rcu *rr_ptr;
Wei Wangc5cff852017-08-21 09:47:10 -070083 struct rcu_head rcu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Wei Wangc757faa2017-10-06 12:06:01 -070086struct fib6_gc_args {
87 int timeout;
88 int more;
89};
90
YOSHIFUJI Hideaki7fc33162006-08-23 17:22:24 -070091#ifndef CONFIG_IPV6_SUBTREES
92#define FIB6_SUBTREE(fn) NULL
93#else
Wei Wang66f5d6c2017-10-06 12:06:10 -070094#define FIB6_SUBTREE(fn) (rcu_dereference_protected((fn)->subtree, 1))
YOSHIFUJI Hideaki7fc33162006-08-23 17:22:24 -070095#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Florian Westphale715b6d2015-01-05 23:57:44 +010097struct mx6_config {
98 const u32 *mx;
99 DECLARE_BITMAP(mx_valid, RTAX_MAX);
100};
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/*
103 * routing information
104 *
105 */
106
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000107struct rt6key {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 struct in6_addr addr;
109 int plen;
110};
111
Thomas Grafc71099a2006-08-04 23:20:06 -0700112struct fib6_table;
113
Wei Wang35732d02017-10-06 12:05:57 -0700114struct rt6_exception_bucket {
115 struct hlist_head chain;
116 int depth;
117};
118
119struct rt6_exception {
120 struct hlist_node hlist;
121 struct rt6_info *rt6i;
122 unsigned long stamp;
123 struct rcu_head rcu;
124};
125
126#define FIB6_EXCEPTION_BUCKET_SIZE_SHIFT 10
127#define FIB6_EXCEPTION_BUCKET_SIZE (1 << FIB6_EXCEPTION_BUCKET_SIZE_SHIFT)
128#define FIB6_MAX_DEPTH 5
129
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000130struct rt6_info {
Changli Gaod8d1f302010-06-10 23:31:35 -0700131 struct dst_entry dst;
David Miller071fb372017-11-28 15:40:15 -0500132 struct rt6_info __rcu *rt6_next;
David Miller3a2232e2017-11-28 15:40:40 -0500133 struct rt6_info *from;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000135 /*
136 * Tail elements of dst_entry (__refcnt etc.)
137 * and these elements (rarely used in hot path) are in
138 * the same cache line.
139 */
140 struct fib6_table *rt6i_table;
Wei Wang4e587ea2017-08-25 15:03:10 -0700141 struct fib6_node __rcu *rt6i_node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143 struct in6_addr rt6i_gateway;
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000144
Nicolas Dichtel51ebd312012-10-22 03:42:09 +0000145 /* Multipath routes:
146 * siblings is a list of rt6_info that have the the same metric/weight,
147 * destination, but not the same gateway. nsiblings is just a cache
148 * to speed up lookup.
149 */
150 struct list_head rt6i_siblings;
151 unsigned int rt6i_nsiblings;
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 atomic_t rt6i_ref;
Herbert Xub4ce9272007-11-13 21:33:32 -0800154
Ido Schimmelfe400792017-08-15 09:09:49 +0200155 unsigned int rt6i_nh_flags;
156
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000157 /* These are in a separate cache line. */
158 struct rt6key rt6i_dst ____cacheline_aligned_in_smp;
159 u32 rt6i_flags;
160 struct rt6key rt6i_src;
Daniel Walterc3968a82011-04-13 21:10:57 +0000161 struct rt6key rt6i_prefsrc;
Herbert Xub4ce9272007-11-13 21:33:32 -0800162
Martin KaFai Lau8d0b94a2015-05-22 20:56:04 -0700163 struct list_head rt6i_uncached;
164 struct uncached_list *rt6i_uncached_list;
165
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000166 struct inet6_dev *rt6i_idev;
Martin KaFai Laud52d3992015-05-22 20:56:06 -0700167 struct rt6_info * __percpu *rt6i_pcpu;
Wei Wang35732d02017-10-06 12:05:57 -0700168 struct rt6_exception_bucket __rcu *rt6i_exception_bucket;
Noriaki TAKAMIYAa47ed4c2007-09-06 03:31:25 -0700169
Hannes Frederic Sowa705f1c82014-09-28 00:46:06 +0200170 u32 rt6i_metric;
Martin KaFai Lau4b32b5a2015-04-28 13:03:06 -0700171 u32 rt6i_pmtu;
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000172 /* more non-fragment space at head required */
173 unsigned short rt6i_nfheader_len;
YOSHIFUJI Hideaki / 吉藤英明bd2c77a2010-03-31 22:24:22 +0000174 u8 rt6i_protocol;
Wei Wang35732d02017-10-06 12:05:57 -0700175 u8 exception_bucket_flushed:1,
Ido Schimmela2c554d2018-01-07 12:45:11 +0200176 should_flush:1,
177 unused:6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178};
179
Wei Wang66f5d6c2017-10-06 12:06:10 -0700180#define for_each_fib6_node_rt_rcu(fn) \
181 for (rt = rcu_dereference((fn)->leaf); rt; \
David Miller071fb372017-11-28 15:40:15 -0500182 rt = rcu_dereference(rt->rt6_next))
Wei Wang66f5d6c2017-10-06 12:06:10 -0700183
184#define for_each_fib6_walker_rt(w) \
185 for (rt = (w)->leaf; rt; \
David Miller071fb372017-11-28 15:40:15 -0500186 rt = rcu_dereference_protected(rt->rt6_next, 1))
Wei Wang66f5d6c2017-10-06 12:06:10 -0700187
YOSHIFUJI Hideaki7a3025b2006-10-13 16:17:25 +0900188static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
189{
190 return ((struct rt6_info *)dst)->rt6i_idev;
191}
192
Gao feng1716a962012-04-06 00:13:10 +0000193static inline void rt6_clean_expires(struct rt6_info *rt)
194{
Gao feng1716a962012-04-06 00:13:10 +0000195 rt->rt6i_flags &= ~RTF_EXPIRES;
Hannes Frederic Sowa01ba16d2013-10-24 10:14:27 +0200196 rt->dst.expires = 0;
Gao feng1716a962012-04-06 00:13:10 +0000197}
198
199static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
200{
Gao feng1716a962012-04-06 00:13:10 +0000201 rt->dst.expires = expires;
YOSHIFUJI Hideaki / 吉藤英明ecd98832013-02-20 00:29:08 +0000202 rt->rt6i_flags |= RTF_EXPIRES;
Gao feng1716a962012-04-06 00:13:10 +0000203}
204
YOSHIFUJI Hideaki / 吉藤英明ecd98832013-02-20 00:29:08 +0000205static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
Gao feng1716a962012-04-06 00:13:10 +0000206{
YOSHIFUJI Hideaki / 吉藤英明ecd98832013-02-20 00:29:08 +0000207 struct rt6_info *rt;
Gao feng1716a962012-04-06 00:13:10 +0000208
David Miller3a2232e2017-11-28 15:40:40 -0500209 for (rt = rt0; rt && !(rt->rt6i_flags & RTF_EXPIRES); rt = rt->from);
YOSHIFUJI Hideaki / 吉藤英明ecd98832013-02-20 00:29:08 +0000210 if (rt && rt != rt0)
211 rt0->dst.expires = rt->dst.expires;
YOSHIFUJI Hideaki / 吉藤英明ecd98832013-02-20 00:29:08 +0000212 dst_set_expires(&rt0->dst, timeout);
213 rt0->rt6i_flags |= RTF_EXPIRES;
Gao feng1716a962012-04-06 00:13:10 +0000214}
215
Wei Wangc5cff852017-08-21 09:47:10 -0700216/* Function to safely get fn->sernum for passed in rt
217 * and store result in passed in cookie.
218 * Return true if we can get cookie safely
219 * Return false if not
220 */
221static inline bool rt6_get_cookie_safe(const struct rt6_info *rt,
222 u32 *cookie)
223{
224 struct fib6_node *fn;
225 bool status = false;
226
227 rcu_read_lock();
228 fn = rcu_dereference(rt->rt6i_node);
229
230 if (fn) {
231 *cookie = fn->fn_sernum;
Wei Wangbbd63f02017-10-06 12:06:07 -0700232 /* pairs with smp_wmb() in fib6_update_sernum_upto_root() */
233 smp_rmb();
Wei Wangc5cff852017-08-21 09:47:10 -0700234 status = true;
235 }
236
237 rcu_read_unlock();
238 return status;
239}
240
Martin KaFai Laub197df42015-05-22 20:56:01 -0700241static inline u32 rt6_get_cookie(const struct rt6_info *rt)
242{
Wei Wangc5cff852017-08-21 09:47:10 -0700243 u32 cookie = 0;
244
Martin KaFai Lau02bcf4e2015-11-11 11:51:08 -0800245 if (rt->rt6i_flags & RTF_PCPU ||
David Miller3a2232e2017-11-28 15:40:40 -0500246 (unlikely(!list_empty(&rt->rt6i_uncached)) && rt->from))
247 rt = rt->from;
Martin KaFai Lau3da59bd2015-05-22 20:56:03 -0700248
Wei Wangc5cff852017-08-21 09:47:10 -0700249 rt6_get_cookie_safe(rt, &cookie);
250
251 return cookie;
Martin KaFai Laub197df42015-05-22 20:56:01 -0700252}
253
Amerigo Wang94e187c2012-10-29 00:13:19 +0000254static inline void ip6_rt_put(struct rt6_info *rt)
255{
256 /* dst_release() accepts a NULL parameter.
257 * We rely on dst being first structure in struct rt6_info
258 */
259 BUILD_BUG_ON(offsetof(struct rt6_info, dst) != 0);
260 dst_release(&rt->dst);
261}
262
Ido Schimmela460aa82017-08-03 13:28:25 +0200263void rt6_free_pcpu(struct rt6_info *non_pcpu_rt);
264
265static inline void rt6_hold(struct rt6_info *rt)
266{
267 atomic_inc(&rt->rt6i_ref);
268}
269
270static inline void rt6_release(struct rt6_info *rt)
271{
272 if (atomic_dec_and_test(&rt->rt6i_ref)) {
273 rt6_free_pcpu(rt);
274 dst_dev_put(&rt->dst);
275 dst_release(&rt->dst);
276 }
277}
278
Hannes Frederic Sowa94b2cfe2014-10-06 19:58:34 +0200279enum fib6_walk_state {
280#ifdef CONFIG_IPV6_SUBTREES
281 FWS_S,
282#endif
283 FWS_L,
284 FWS_R,
285 FWS_C,
286 FWS_U
287};
288
289struct fib6_walker {
Alexey Dobriyanbbef49d2010-02-18 08:13:30 +0000290 struct list_head lh;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 struct fib6_node *root, *node;
292 struct rt6_info *leaf;
Hannes Frederic Sowa94b2cfe2014-10-06 19:58:34 +0200293 enum fib6_walk_state state;
Patrick McHardy2bec5a32010-02-08 05:19:03 +0000294 unsigned int skip;
295 unsigned int count;
Hannes Frederic Sowa94b2cfe2014-10-06 19:58:34 +0200296 int (*func)(struct fib6_walker *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 void *args;
298};
299
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300struct rt6_statistics {
Wei Wang81eb8442017-10-06 12:06:11 -0700301 __u32 fib_nodes; /* all fib6 nodes */
302 __u32 fib_route_nodes; /* intermediate nodes */
303 __u32 fib_rt_entries; /* rt entries in fib table */
304 __u32 fib_rt_cache; /* cached rt entries in exception table */
305 __u32 fib_discarded_routes; /* total number of routes delete */
306
307 /* The following stats are not protected by any lock */
308 atomic_t fib_rt_alloc; /* total number of routes alloced */
309 atomic_t fib_rt_uncache; /* rt entries in uncached list */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310};
311
312#define RTN_TL_ROOT 0x0001
313#define RTN_ROOT 0x0002 /* tree root node */
314#define RTN_RTINFO 0x0004 /* node with valid routing info */
315
316/*
317 * priority levels (or metrics)
318 *
319 */
320
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
Thomas Grafc71099a2006-08-04 23:20:06 -0700322struct fib6_table {
323 struct hlist_node tb6_hlist;
324 u32 tb6_id;
Wei Wang66f5d6c2017-10-06 12:06:10 -0700325 spinlock_t tb6_lock;
Thomas Grafc71099a2006-08-04 23:20:06 -0700326 struct fib6_node tb6_root;
David S. Miller8e773272012-06-11 00:01:52 -0700327 struct inet_peer_base tb6_peers;
David Ahern830218c2016-10-24 10:52:35 -0700328 unsigned int flags;
Ido Schimmele1ee0a52017-08-03 13:28:19 +0200329 unsigned int fib_seq;
David Ahern830218c2016-10-24 10:52:35 -0700330#define RT6_TABLE_HAS_DFLT_ROUTER BIT(0)
Thomas Grafc71099a2006-08-04 23:20:06 -0700331};
332
333#define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC
334#define RT6_TABLE_MAIN RT_TABLE_MAIN
Thomas Grafc71099a2006-08-04 23:20:06 -0700335#define RT6_TABLE_DFLT RT6_TABLE_MAIN
336#define RT6_TABLE_INFO RT6_TABLE_MAIN
337#define RT6_TABLE_PREFIX RT6_TABLE_MAIN
338
339#ifdef CONFIG_IPV6_MULTIPLE_TABLES
340#define FIB6_TABLE_MIN 1
341#define FIB6_TABLE_MAX RT_TABLE_MAX
Thomas Graf101367c2006-08-04 03:39:02 -0700342#define RT6_TABLE_LOCAL RT_TABLE_LOCAL
Thomas Grafc71099a2006-08-04 23:20:06 -0700343#else
344#define FIB6_TABLE_MIN RT_TABLE_MAIN
345#define FIB6_TABLE_MAX FIB6_TABLE_MIN
Thomas Graf101367c2006-08-04 03:39:02 -0700346#define RT6_TABLE_LOCAL RT6_TABLE_MAIN
Thomas Grafc71099a2006-08-04 23:20:06 -0700347#endif
348
Daniel Lezcano8ed67782008-03-04 13:48:30 -0800349typedef struct rt6_info *(*pol_lookup_t)(struct net *,
350 struct fib6_table *,
David S. Miller4c9483b2011-03-12 16:22:43 -0500351 struct flowi6 *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
Ido Schimmeldf77fe42017-08-03 13:28:17 +0200353struct fib6_entry_notifier_info {
354 struct fib_notifier_info info; /* must be first */
355 struct rt6_info *rt;
356};
357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358/*
359 * exported functions
360 */
361
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700362struct fib6_table *fib6_get_table(struct net *net, u32 id);
363struct fib6_table *fib6_new_table(struct net *net, u32 id);
364struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
365 int flags, pol_lookup_t lookup);
Thomas Grafc71099a2006-08-04 23:20:06 -0700366
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700367struct fib6_node *fib6_lookup(struct fib6_node *root,
368 const struct in6_addr *daddr,
369 const struct in6_addr *saddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700371struct fib6_node *fib6_locate(struct fib6_node *root,
372 const struct in6_addr *daddr, int dst_len,
Wei Wang38fbeee2017-10-06 12:06:02 -0700373 const struct in6_addr *saddr, int src_len,
374 bool exact_match);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700376void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *arg),
Li RongQing0c3584d2013-12-27 16:32:38 +0800377 void *arg);
Thomas Grafc71099a2006-08-04 23:20:06 -0700378
Florian Westphale715b6d2015-01-05 23:57:44 +0100379int fib6_add(struct fib6_node *root, struct rt6_info *rt,
David Ahern333c4302017-05-21 10:12:04 -0600380 struct nl_info *info, struct mx6_config *mxc,
381 struct netlink_ext_ack *extack);
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700382int fib6_del(struct rt6_info *rt, struct nl_info *info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
Roopa Prabhu37a1d362015-09-13 10:18:33 -0700384void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info,
385 unsigned int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700387void fib6_run_gc(unsigned long expires, struct net *net, bool force);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700389void fib6_gc_cleanup(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700391int fib6_init(void);
Thomas Graf101367c2006-08-04 03:39:02 -0700392
Hannes Frederic Sowa8d2ca1d2013-09-21 16:55:59 +0200393int ipv6_route_open(struct inode *inode, struct file *file);
394
Ido Schimmel16ab6d72017-08-03 13:28:16 +0200395int call_fib6_notifier(struct notifier_block *nb, struct net *net,
396 enum fib_event_type event_type,
397 struct fib_notifier_info *info);
398int call_fib6_notifiers(struct net *net, enum fib_event_type event_type,
399 struct fib_notifier_info *info);
400
401int __net_init fib6_notifier_init(struct net *net);
402void __net_exit fib6_notifier_exit(struct net *net);
403
Ido Schimmele1ee0a52017-08-03 13:28:19 +0200404unsigned int fib6_tables_seq_read(struct net *net);
405int fib6_tables_dump(struct net *net, struct notifier_block *nb);
406
Wei Wang180ca442017-10-06 12:05:56 -0700407void fib6_update_sernum(struct rt6_info *rt);
Ido Schimmel4a8e56e2018-01-07 12:45:13 +0200408void fib6_update_sernum_upto_root(struct net *net, struct rt6_info *rt);
Wei Wang180ca442017-10-06 12:05:56 -0700409
Daniel Lezcano7e5449c2007-12-08 00:14:54 -0800410#ifdef CONFIG_IPV6_MULTIPLE_TABLES
Joe Perches5c3a0fd2013-09-21 10:22:42 -0700411int fib6_rules_init(void);
412void fib6_rules_cleanup(void);
Ido Schimmele3ea9732017-08-03 13:28:15 +0200413bool fib6_rule_default(const struct fib_rule *rule);
Ido Schimmeldcb18f72017-08-03 13:28:18 +0200414int fib6_rules_dump(struct net *net, struct notifier_block *nb);
415unsigned int fib6_rules_seq_read(struct net *net);
Daniel Lezcano7e5449c2007-12-08 00:14:54 -0800416#else
417static inline int fib6_rules_init(void)
418{
419 return 0;
420}
421static inline void fib6_rules_cleanup(void)
422{
423 return ;
424}
Ido Schimmele3ea9732017-08-03 13:28:15 +0200425static inline bool fib6_rule_default(const struct fib_rule *rule)
426{
427 return true;
428}
Ido Schimmeldcb18f72017-08-03 13:28:18 +0200429static inline int fib6_rules_dump(struct net *net, struct notifier_block *nb)
430{
431 return 0;
432}
433static inline unsigned int fib6_rules_seq_read(struct net *net)
434{
435 return 0;
436}
Daniel Lezcano7e5449c2007-12-08 00:14:54 -0800437#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438#endif