2 * Linux INET6 implementation
5 * Pedro Roque <pedro_m@yahoo.com>
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.
18 #include <linux/ipv6_route.h>
22 #include <linux/rtnetlink.h>
28 struct fib6_node *parent;
29 struct fib6_node *left;
30 struct fib6_node *right;
32 struct fib6_node *subtree;
34 struct rt6_info *leaf;
36 __u16 fn_bit; /* bit key */
57 struct rt6_info *next;
60 #define rt6i_dev u.dst.dev
61 #define rt6i_nexthop u.dst.neighbour
62 #define rt6i_expires u.dst.expires
64 struct fib6_node *rt6i_node;
66 struct in6_addr rt6i_gateway;
74 struct flow_rule *rt6iu_flowr;
75 struct flow_filter *rt6iu_filter;
78 #define rt6i_flowr flow_u.rt6iu_flowr
79 #define rt6i_filter flow_u.rt6iu_filter
81 struct rt6key rt6i_dst;
82 struct rt6key rt6i_src;
89 struct fib6_walker_t *prev, *next;
90 struct fib6_node *root, *node;
91 struct rt6_info *leaf;
94 int (*func)(struct fib6_walker_t *);
98 extern struct fib6_walker_t fib6_walker_list;
99 extern rwlock_t fib6_walker_lock;
101 static inline void fib6_walker_link(struct fib6_walker_t *w)
103 write_lock_bh(&fib6_walker_lock);
104 w->next = fib6_walker_list.next;
105 w->prev = &fib6_walker_list;
108 write_unlock_bh(&fib6_walker_lock);
111 static inline void fib6_walker_unlink(struct fib6_walker_t *w)
113 write_lock_bh(&fib6_walker_lock);
114 w->next->prev = w->prev;
115 w->prev->next = w->next;
116 w->prev = w->next = w;
117 write_unlock_bh(&fib6_walker_lock);
120 struct rt6_statistics {
122 __u32 fib_route_nodes;
123 __u32 fib_rt_alloc; /* permanent routes */
124 __u32 fib_rt_entries; /* rt entries in table */
125 __u32 fib_rt_cache; /* cache routes */
128 #define RTN_TL_ROOT 0x0001
129 #define RTN_ROOT 0x0002 /* tree root node */
130 #define RTN_RTINFO 0x0004 /* node with valid routing info */
133 * priority levels (or metrics)
137 #define RTPRI_FIREWALL 8 /* Firewall control information */
138 #define RTPRI_FLOW 16 /* Flow based forwarding rules */
139 #define RTPRI_KERN_CTL 32 /* Kernel control routes */
141 #define RTPRI_USER_MIN 256 /* Mimimum user priority */
142 #define RTPRI_USER_MAX 1024 /* Maximum user priority */
144 #define RTPRI_KERN_DFLT 4096 /* Kernel default routes */
146 #define MAX_FLOW_BACKTRACE 32
149 typedef void (*f_pnode)(struct fib6_node *fn, void *);
151 extern struct fib6_node ip6_routing_table;
157 extern struct fib6_node *fib6_lookup(struct fib6_node *root,
158 struct in6_addr *daddr,
159 struct in6_addr *saddr);
161 struct fib6_node *fib6_locate(struct fib6_node *root,
162 struct in6_addr *daddr, int dst_len,
163 struct in6_addr *saddr, int src_len);
165 extern void fib6_clean_tree(struct fib6_node *root,
166 int (*func)(struct rt6_info *, void *arg),
167 int prune, void *arg);
169 extern int fib6_walk(struct fib6_walker_t *w);
170 extern int fib6_walk_continue(struct fib6_walker_t *w);
172 extern int fib6_add(struct fib6_node *root,
174 struct nlmsghdr *nlh,
175 struct netlink_skb_parms *req);
177 extern int fib6_del(struct rt6_info *rt,
178 struct nlmsghdr *nlh,
179 struct netlink_skb_parms *req);
181 extern void inet6_rt_notify(int event, struct rt6_info *rt,
182 struct nlmsghdr *nlh,
183 struct netlink_skb_parms *req);
185 extern void fib6_run_gc(unsigned long dummy);
187 extern void fib6_gc_cleanup(void);
189 extern void fib6_init(void);