]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/net/ip6_fib.h
[IPv6] route: Simplify ip6_ins_rt()
[mirror_ubuntu-eoan-kernel.git] / include / net / ip6_fib.h
CommitLineData
1da177e4
LT
1/*
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
16#ifdef __KERNEL__
17
18#include <linux/ipv6_route.h>
19
20#include <net/dst.h>
21#include <net/flow.h>
22#include <linux/rtnetlink.h>
23#include <linux/spinlock.h>
24
25struct rt6_info;
26
27struct fib6_node
28{
29 struct fib6_node *parent;
30 struct fib6_node *left;
31 struct fib6_node *right;
32
33 struct fib6_node *subtree;
34
35 struct rt6_info *leaf;
36
37 __u16 fn_bit; /* bit key */
38 __u16 fn_flags;
39 __u32 fn_sernum;
40};
41
42
43/*
44 * routing information
45 *
46 */
47
48struct rt6key
49{
50 struct in6_addr addr;
51 int plen;
52};
53
c71099ac
TG
54struct fib6_table;
55
1da177e4
LT
56struct rt6_info
57{
58 union {
59 struct dst_entry dst;
60 struct rt6_info *next;
61 } u;
62
63 struct inet6_dev *rt6i_idev;
64
65#define rt6i_dev u.dst.dev
66#define rt6i_nexthop u.dst.neighbour
67#define rt6i_expires u.dst.expires
68
69 struct fib6_node *rt6i_node;
70
71 struct in6_addr rt6i_gateway;
72
73 u32 rt6i_flags;
74 u32 rt6i_metric;
75 atomic_t rt6i_ref;
c71099ac 76 struct fib6_table *rt6i_table;
1da177e4
LT
77
78 struct rt6key rt6i_dst;
79 struct rt6key rt6i_src;
80
81 u8 rt6i_protocol;
82};
83
84struct fib6_walker_t
85{
86 struct fib6_walker_t *prev, *next;
87 struct fib6_node *root, *node;
88 struct rt6_info *leaf;
89 unsigned char state;
90 unsigned char prune;
91 int (*func)(struct fib6_walker_t *);
92 void *args;
93};
94
1da177e4
LT
95struct rt6_statistics {
96 __u32 fib_nodes;
97 __u32 fib_route_nodes;
98 __u32 fib_rt_alloc; /* permanent routes */
99 __u32 fib_rt_entries; /* rt entries in table */
100 __u32 fib_rt_cache; /* cache routes */
101 __u32 fib_discarded_routes;
102};
103
104#define RTN_TL_ROOT 0x0001
105#define RTN_ROOT 0x0002 /* tree root node */
106#define RTN_RTINFO 0x0004 /* node with valid routing info */
107
108/*
109 * priority levels (or metrics)
110 *
111 */
112
113#define RTPRI_FIREWALL 8 /* Firewall control information */
114#define RTPRI_FLOW 16 /* Flow based forwarding rules */
115#define RTPRI_KERN_CTL 32 /* Kernel control routes */
116
117#define RTPRI_USER_MIN 256 /* Mimimum user priority */
118#define RTPRI_USER_MAX 1024 /* Maximum user priority */
119
120#define RTPRI_KERN_DFLT 4096 /* Kernel default routes */
121
122#define MAX_FLOW_BACKTRACE 32
123
124
125typedef void (*f_pnode)(struct fib6_node *fn, void *);
126
c71099ac
TG
127struct fib6_table {
128 struct hlist_node tb6_hlist;
129 u32 tb6_id;
130 rwlock_t tb6_lock;
131 struct fib6_node tb6_root;
132};
133
134#define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC
135#define RT6_TABLE_MAIN RT_TABLE_MAIN
c71099ac
TG
136#define RT6_TABLE_DFLT RT6_TABLE_MAIN
137#define RT6_TABLE_INFO RT6_TABLE_MAIN
138#define RT6_TABLE_PREFIX RT6_TABLE_MAIN
139
140#ifdef CONFIG_IPV6_MULTIPLE_TABLES
141#define FIB6_TABLE_MIN 1
142#define FIB6_TABLE_MAX RT_TABLE_MAX
101367c2 143#define RT6_TABLE_LOCAL RT_TABLE_LOCAL
c71099ac
TG
144#else
145#define FIB6_TABLE_MIN RT_TABLE_MAIN
146#define FIB6_TABLE_MAX FIB6_TABLE_MIN
101367c2 147#define RT6_TABLE_LOCAL RT6_TABLE_MAIN
c71099ac
TG
148#endif
149
150#define RT6_F_STRICT 1
151#define RT6_F_HAS_SADDR 2
152
153typedef struct rt6_info *(*pol_lookup_t)(struct fib6_table *,
154 struct flowi *, int);
1da177e4
LT
155
156/*
157 * exported functions
158 */
159
c71099ac
TG
160extern struct fib6_table * fib6_get_table(u32 id);
161extern struct fib6_table * fib6_new_table(u32 id);
162extern struct dst_entry * fib6_rule_lookup(struct flowi *fl, int flags,
163 pol_lookup_t lookup);
164
1da177e4
LT
165extern struct fib6_node *fib6_lookup(struct fib6_node *root,
166 struct in6_addr *daddr,
167 struct in6_addr *saddr);
168
169struct fib6_node *fib6_locate(struct fib6_node *root,
170 struct in6_addr *daddr, int dst_len,
171 struct in6_addr *saddr, int src_len);
172
c71099ac
TG
173extern void fib6_clean_all(int (*func)(struct rt6_info *, void *arg),
174 int prune, void *arg);
175
1da177e4
LT
176extern int fib6_add(struct fib6_node *root,
177 struct rt6_info *rt,
178 struct nlmsghdr *nlh,
0d51aa80
JHS
179 void *rtattr,
180 struct netlink_skb_parms *req);
1da177e4
LT
181
182extern int fib6_del(struct rt6_info *rt,
183 struct nlmsghdr *nlh,
0d51aa80
JHS
184 void *rtattr,
185 struct netlink_skb_parms *req);
1da177e4
LT
186
187extern void inet6_rt_notify(int event, struct rt6_info *rt,
0d51aa80
JHS
188 struct nlmsghdr *nlh,
189 struct netlink_skb_parms *req);
1da177e4
LT
190
191extern void fib6_run_gc(unsigned long dummy);
192
193extern void fib6_gc_cleanup(void);
194
195extern void fib6_init(void);
101367c2
TG
196
197extern void fib6_rules_init(void);
198extern void fib6_rules_cleanup(void);
199extern int fib6_rules_dump(struct sk_buff *,
200 struct netlink_callback *);
201
1da177e4
LT
202#endif
203#endif