2 * Linux INET6 implementation
5 * Pedro Roque <roque@di.fc.ul.pt>
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>
23 #include <linux/spinlock.h>
29 struct fib6_node
*parent
;
30 struct fib6_node
*left
;
31 struct fib6_node
*right
;
33 struct fib6_node
*subtree
;
35 struct rt6_info
*leaf
;
37 __u16 fn_bit
; /* bit key */
58 struct rt6_info
*next
;
61 struct inet6_dev
*rt6i_idev
;
63 #define rt6i_dev u.dst.dev
64 #define rt6i_nexthop u.dst.neighbour
65 #define rt6i_expires u.dst.expires
67 struct fib6_node
*rt6i_node
;
69 struct in6_addr rt6i_gateway
;
75 struct rt6key rt6i_dst
;
76 struct rt6key rt6i_src
;
83 struct fib6_walker_t
*prev
, *next
;
84 struct fib6_node
*root
, *node
;
85 struct rt6_info
*leaf
;
88 int (*func
)(struct fib6_walker_t
*);
92 extern struct fib6_walker_t fib6_walker_list
;
93 extern rwlock_t fib6_walker_lock
;
95 static inline void fib6_walker_link(struct fib6_walker_t
*w
)
97 write_lock_bh(&fib6_walker_lock
);
98 w
->next
= fib6_walker_list
.next
;
99 w
->prev
= &fib6_walker_list
;
102 write_unlock_bh(&fib6_walker_lock
);
105 static inline void fib6_walker_unlink(struct fib6_walker_t
*w
)
107 write_lock_bh(&fib6_walker_lock
);
108 w
->next
->prev
= w
->prev
;
109 w
->prev
->next
= w
->next
;
110 w
->prev
= w
->next
= w
;
111 write_unlock_bh(&fib6_walker_lock
);
114 struct rt6_statistics
{
116 __u32 fib_route_nodes
;
117 __u32 fib_rt_alloc
; /* permanent routes */
118 __u32 fib_rt_entries
; /* rt entries in table */
119 __u32 fib_rt_cache
; /* cache routes */
120 __u32 fib_discarded_routes
;
123 #define RTN_TL_ROOT 0x0001
124 #define RTN_ROOT 0x0002 /* tree root node */
125 #define RTN_RTINFO 0x0004 /* node with valid routing info */
128 * priority levels (or metrics)
132 #define RTPRI_FIREWALL 8 /* Firewall control information */
133 #define RTPRI_FLOW 16 /* Flow based forwarding rules */
134 #define RTPRI_KERN_CTL 32 /* Kernel control routes */
136 #define RTPRI_USER_MIN 256 /* Mimimum user priority */
137 #define RTPRI_USER_MAX 1024 /* Maximum user priority */
139 #define RTPRI_KERN_DFLT 4096 /* Kernel default routes */
141 #define MAX_FLOW_BACKTRACE 32
144 typedef void (*f_pnode
)(struct fib6_node
*fn
, void *);
146 extern struct fib6_node ip6_routing_table
;
152 extern struct fib6_node
*fib6_lookup(struct fib6_node
*root
,
153 struct in6_addr
*daddr
,
154 struct in6_addr
*saddr
);
156 struct fib6_node
*fib6_locate(struct fib6_node
*root
,
157 struct in6_addr
*daddr
, int dst_len
,
158 struct in6_addr
*saddr
, int src_len
);
160 extern void fib6_clean_tree(struct fib6_node
*root
,
161 int (*func
)(struct rt6_info
*, void *arg
),
162 int prune
, void *arg
);
164 extern int fib6_walk(struct fib6_walker_t
*w
);
165 extern int fib6_walk_continue(struct fib6_walker_t
*w
);
167 extern int fib6_add(struct fib6_node
*root
,
169 struct nlmsghdr
*nlh
,
171 struct netlink_skb_parms
*req
);
173 extern int fib6_del(struct rt6_info
*rt
,
174 struct nlmsghdr
*nlh
,
176 struct netlink_skb_parms
*req
);
178 extern void inet6_rt_notify(int event
, struct rt6_info
*rt
,
179 struct nlmsghdr
*nlh
,
180 struct netlink_skb_parms
*req
);
182 extern void fib6_run_gc(unsigned long dummy
);
184 extern void fib6_gc_cleanup(void);
186 extern void fib6_init(void);