Blame view
include/net/ip_fib.h
7.14 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* * INET An implementation of the TCP/IP protocol suite for the LINUX * operating system. INET is implemented using the BSD Socket * interface as the means of communication with the user level. * * Definitions for the Forwarding Information Base. * * Authors: A.N.Kuznetsov, <kuznet@ms2.inr.ac.ru> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #ifndef _NET_IP_FIB_H #define _NET_IP_FIB_H |
1da177e4c Linux-2.6.12-rc2 |
18 19 |
#include <net/flow.h> #include <linux/seq_file.h> |
e1ef4bf23 [IPV4]: Use Proto... |
20 |
#include <net/fib_rules.h> |
1da177e4c Linux-2.6.12-rc2 |
21 |
|
4e902c574 [IPv4]: FIB confi... |
22 |
struct fib_config { |
4e902c574 [IPv4]: FIB confi... |
23 |
u8 fc_dst_len; |
4e902c574 [IPv4]: FIB confi... |
24 25 26 27 |
u8 fc_tos; u8 fc_protocol; u8 fc_scope; u8 fc_type; |
b52f070c9 [IPv4] fib: Remov... |
28 |
/* 3 bytes unused */ |
4e902c574 [IPv4]: FIB confi... |
29 |
u32 fc_table; |
6d85c10ab [IPV4]: struct fi... |
30 |
__be32 fc_dst; |
6d85c10ab [IPV4]: struct fi... |
31 |
__be32 fc_gw; |
4e902c574 [IPv4]: FIB confi... |
32 33 34 |
int fc_oif; u32 fc_flags; u32 fc_priority; |
6d85c10ab [IPV4]: struct fi... |
35 |
__be32 fc_prefsrc; |
4e902c574 [IPv4]: FIB confi... |
36 37 38 39 40 |
struct nlattr *fc_mx; struct rtnexthop *fc_mp; int fc_mx_len; int fc_mp_len; u32 fc_flow; |
4e902c574 [IPv4]: FIB confi... |
41 42 43 |
u32 fc_nlflags; struct nl_info fc_nlinfo; }; |
1da177e4c Linux-2.6.12-rc2 |
44 45 46 47 48 49 50 51 52 53 54 55 56 |
struct fib_info; struct fib_nh { struct net_device *nh_dev; struct hlist_node nh_hash; struct fib_info *nh_parent; unsigned nh_flags; unsigned char nh_scope; #ifdef CONFIG_IP_ROUTE_MULTIPATH int nh_weight; int nh_power; #endif |
c7066f70d netfilter: fix Kc... |
57 |
#ifdef CONFIG_IP_ROUTE_CLASSID |
1da177e4c Linux-2.6.12-rc2 |
58 59 60 |
__u32 nh_tclassid; #endif int nh_oif; |
ed49e3caa [IPV4]: fib_hn ->... |
61 |
__be32 nh_gw; |
1fc050a13 ipv4: Cache sourc... |
62 |
__be32 nh_saddr; |
436c3b66e ipv4: Invalidate ... |
63 |
int nh_saddr_genid; |
1da177e4c Linux-2.6.12-rc2 |
64 65 66 67 68 69 70 71 72 |
}; /* * This structure contains data shared by many of routes. */ struct fib_info { struct hlist_node fib_hash; struct hlist_node fib_lhash; |
7462bd744 [NETNS]: Add a na... |
73 |
struct net *fib_net; |
1da177e4c Linux-2.6.12-rc2 |
74 75 |
int fib_treeref; atomic_t fib_clntref; |
1da177e4c Linux-2.6.12-rc2 |
76 |
unsigned fib_flags; |
37e826c51 ipv4: Fix nexthop... |
77 78 79 |
unsigned char fib_dead; unsigned char fib_protocol; unsigned char fib_scope; |
b83738ae0 [IPV4]: FIB_RES_P... |
80 |
__be32 fib_prefsrc; |
1da177e4c Linux-2.6.12-rc2 |
81 |
u32 fib_priority; |
9c150e82a ipv4: Allocate fi... |
82 |
u32 *fib_metrics; |
1da177e4c Linux-2.6.12-rc2 |
83 84 85 86 87 88 89 90 |
#define fib_mtu fib_metrics[RTAX_MTU-1] #define fib_window fib_metrics[RTAX_WINDOW-1] #define fib_rtt fib_metrics[RTAX_RTT-1] #define fib_advmss fib_metrics[RTAX_ADVMSS-1] int fib_nhs; #ifdef CONFIG_IP_ROUTE_MULTIPATH int fib_power; #endif |
ebc0ffae5 fib: RCU conversi... |
91 |
struct rcu_head rcu; |
1da177e4c Linux-2.6.12-rc2 |
92 93 94 95 96 97 98 99 |
struct fib_nh fib_nh[0]; #define fib_dev fib_nh[0].nh_dev }; #ifdef CONFIG_IP_MULTIPLE_TABLES struct fib_rule; #endif |
5b4704419 ipv4: Remember FI... |
100 |
struct fib_table; |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 104 105 |
struct fib_result { unsigned char prefixlen; unsigned char nh_sel; unsigned char type; unsigned char scope; |
1da177e4c Linux-2.6.12-rc2 |
106 |
struct fib_info *fi; |
5b4704419 ipv4: Remember FI... |
107 108 |
struct fib_table *table; struct list_head *fa_head; |
1da177e4c Linux-2.6.12-rc2 |
109 110 111 112 |
#ifdef CONFIG_IP_MULTIPLE_TABLES struct fib_rule *r; #endif }; |
246955fe4 [NETLINK]: fib_lo... |
113 |
struct fib_result_nl { |
80e856e16 [IPV4]: annotate ... |
114 |
__be32 fl_addr; /* To be looked up*/ |
5f300893f [IPV4] nl_fib_loo... |
115 |
u32 fl_mark; |
246955fe4 [NETLINK]: fib_lo... |
116 117 118 119 120 121 122 123 124 125 126 |
unsigned char fl_tos; unsigned char fl_scope; unsigned char tb_id_in; unsigned char tb_id; /* Results */ unsigned char prefixlen; unsigned char nh_sel; unsigned char type; unsigned char scope; int err; }; |
1da177e4c Linux-2.6.12-rc2 |
127 128 129 130 |
#ifdef CONFIG_IP_ROUTE_MULTIPATH #define FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel]) |
1da177e4c Linux-2.6.12-rc2 |
131 |
|
93456b6d7 [IPV4]: Unify acc... |
132 |
#define FIB_TABLE_HASHSZ 2 |
1da177e4c Linux-2.6.12-rc2 |
133 134 135 |
#else /* CONFIG_IP_ROUTE_MULTIPATH */ #define FIB_RES_NH(res) ((res).fi->fib_nh[0]) |
1da177e4c Linux-2.6.12-rc2 |
136 |
|
93456b6d7 [IPV4]: Unify acc... |
137 |
#define FIB_TABLE_HASHSZ 256 |
1da177e4c Linux-2.6.12-rc2 |
138 |
#endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
436c3b66e ipv4: Invalidate ... |
139 140 141 142 143 144 145 |
extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh); #define FIB_RES_SADDR(net, res) \ ((FIB_RES_NH(res).nh_saddr_genid == \ atomic_read(&(net)->ipv4.dev_addr_genid)) ? \ FIB_RES_NH(res).nh_saddr : \ fib_info_update_nh_saddr((net), &FIB_RES_NH(res))) |
1da177e4c Linux-2.6.12-rc2 |
146 147 148 |
#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) #define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) #define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) |
436c3b66e ipv4: Invalidate ... |
149 150 |
#define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \ FIB_RES_SADDR(net, res)) |
1fc050a13 ipv4: Cache sourc... |
151 |
|
1da177e4c Linux-2.6.12-rc2 |
152 |
struct fib_table { |
1af5a8c4a [IPV4]: Increase ... |
153 |
struct hlist_node tb_hlist; |
2dfe55b47 [NET]: Use u32 fo... |
154 |
u32 tb_id; |
971b893e7 [IPV4]: last defa... |
155 |
int tb_default; |
21d8c49e0 ipv4: Call fib_se... |
156 157 |
int tb_num_default; unsigned long tb_data[0]; |
1da177e4c Linux-2.6.12-rc2 |
158 |
}; |
22bd5b9b1 ipv4: Pass ipv4 f... |
159 |
extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, |
ebc0ffae5 fib: RCU conversi... |
160 |
struct fib_result *res, int fib_flags); |
16c6cf8bb ipv4: fib table a... |
161 162 163 164 165 |
extern int fib_table_insert(struct fib_table *, struct fib_config *); extern int fib_table_delete(struct fib_table *, struct fib_config *); extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, struct netlink_callback *cb); extern int fib_table_flush(struct fib_table *table); |
4aa2c466a fib: Fix fib zone... |
166 |
extern void fib_free_table(struct fib_table *tb); |
16c6cf8bb ipv4: fib table a... |
167 |
|
1da177e4c Linux-2.6.12-rc2 |
168 |
#ifndef CONFIG_IP_MULTIPLE_TABLES |
93456b6d7 [IPV4]: Unify acc... |
169 170 |
#define TABLE_LOCAL_INDEX 0 #define TABLE_MAIN_INDEX 1 |
1da177e4c Linux-2.6.12-rc2 |
171 |
|
8ad4942cd [NETNS]: Add netn... |
172 |
static inline struct fib_table *fib_get_table(struct net *net, u32 id) |
1da177e4c Linux-2.6.12-rc2 |
173 |
{ |
93456b6d7 [IPV4]: Unify acc... |
174 175 176 |
struct hlist_head *ptr; ptr = id == RT_TABLE_LOCAL ? |
e4aef8aea [NETNS]: Place fi... |
177 178 |
&net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] : &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]; |
93456b6d7 [IPV4]: Unify acc... |
179 |
return hlist_entry(ptr->first, struct fib_table, tb_hlist); |
1da177e4c Linux-2.6.12-rc2 |
180 |
} |
8ad4942cd [NETNS]: Add netn... |
181 |
static inline struct fib_table *fib_new_table(struct net *net, u32 id) |
1da177e4c Linux-2.6.12-rc2 |
182 |
{ |
8ad4942cd [NETNS]: Add netn... |
183 |
return fib_get_table(net, id); |
1da177e4c Linux-2.6.12-rc2 |
184 |
} |
22bd5b9b1 ipv4: Pass ipv4 f... |
185 |
static inline int fib_lookup(struct net *net, const struct flowi4 *flp, |
da0e28cb6 [NETNS]: Add netn... |
186 |
struct fib_result *res) |
1da177e4c Linux-2.6.12-rc2 |
187 |
{ |
93456b6d7 [IPV4]: Unify acc... |
188 |
struct fib_table *table; |
da0e28cb6 [NETNS]: Add netn... |
189 |
table = fib_get_table(net, RT_TABLE_LOCAL); |
ebc0ffae5 fib: RCU conversi... |
190 |
if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF)) |
93456b6d7 [IPV4]: Unify acc... |
191 |
return 0; |
da0e28cb6 [NETNS]: Add netn... |
192 |
table = fib_get_table(net, RT_TABLE_MAIN); |
ebc0ffae5 fib: RCU conversi... |
193 |
if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF)) |
93456b6d7 [IPV4]: Unify acc... |
194 195 |
return 0; return -ENETUNREACH; |
1da177e4c Linux-2.6.12-rc2 |
196 |
} |
1da177e4c Linux-2.6.12-rc2 |
197 |
#else /* CONFIG_IP_MULTIPLE_TABLES */ |
7b1a74fdb [NETNS]: Refactor... |
198 199 |
extern int __net_init fib4_rules_init(struct net *net); extern void __net_exit fib4_rules_exit(struct net *net); |
c3e9a353d [IPV4]: Compact s... |
200 |
|
c7066f70d netfilter: fix Kc... |
201 |
#ifdef CONFIG_IP_ROUTE_CLASSID |
982721f39 ipv4: Use const'i... |
202 |
extern u32 fib_rules_tclass(const struct fib_result *res); |
c3e9a353d [IPV4]: Compact s... |
203 |
#endif |
22bd5b9b1 ipv4: Pass ipv4 f... |
204 |
extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res); |
1da177e4c Linux-2.6.12-rc2 |
205 |
|
8ad4942cd [NETNS]: Add netn... |
206 207 |
extern struct fib_table *fib_new_table(struct net *net, u32 id); extern struct fib_table *fib_get_table(struct net *net, u32 id); |
1da177e4c Linux-2.6.12-rc2 |
208 209 210 211 |
#endif /* CONFIG_IP_MULTIPLE_TABLES */ /* Exported by fib_frontend.c */ |
ef7c79ed6 [NETLINK]: Mark n... |
212 |
extern const struct nla_policy rtm_ipv4_policy[]; |
1da177e4c Linux-2.6.12-rc2 |
213 |
extern void ip_fib_init(void); |
5c04c819a fib_validate_sour... |
214 215 216 |
extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, u8 tos, int oif, struct net_device *dev, __be32 *spec_dst, u32 *itag); |
0c838ff1a ipv4: Consolidate... |
217 |
extern void fib_select_default(struct fib_result *res); |
14c850212 [INET_SOCK]: Move... |
218 |
|
1da177e4c Linux-2.6.12-rc2 |
219 |
/* Exported by fib_semantics.c */ |
d878e72e4 [IPV4]: ip_fib_ch... |
220 |
extern int ip_fib_check_default(__be32 gw, struct net_device *dev); |
85326fa54 [IPV4]: fib_sync_... |
221 |
extern int fib_sync_down_dev(struct net_device *dev, int force); |
4814bdbd5 [NETNS]: Lookup i... |
222 |
extern int fib_sync_down_addr(struct net *net, __be32 local); |
1fc050a13 ipv4: Cache sourc... |
223 |
extern void fib_update_nh_saddrs(struct net_device *dev); |
1da177e4c Linux-2.6.12-rc2 |
224 |
extern int fib_sync_up(struct net_device *dev); |
1b7fe5932 ipv4: Kill flowi ... |
225 |
extern void fib_select_multipath(struct fib_result *res); |
1da177e4c Linux-2.6.12-rc2 |
226 |
|
5348ba85a ipv4: Update some... |
227 228 229 |
/* Exported by fib_trie.c */ extern void fib_trie_init(void); extern struct fib_table *fib_trie_table(u32 id); |
1da177e4c Linux-2.6.12-rc2 |
230 |
|
b6bf3ca03 ipv4: Mark fib_co... |
231 |
static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) |
1da177e4c Linux-2.6.12-rc2 |
232 |
{ |
c7066f70d netfilter: fix Kc... |
233 |
#ifdef CONFIG_IP_ROUTE_CLASSID |
1da177e4c Linux-2.6.12-rc2 |
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
#ifdef CONFIG_IP_MULTIPLE_TABLES u32 rtag; #endif *itag = FIB_RES_NH(*res).nh_tclassid<<16; #ifdef CONFIG_IP_MULTIPLE_TABLES rtag = fib_rules_tclass(res); if (*itag == 0) *itag = (rtag<<16); *itag |= (rtag>>16); #endif #endif } extern void free_fib_info(struct fib_info *fi); static inline void fib_info_put(struct fib_info *fi) { if (atomic_dec_and_test(&fi->fib_clntref)) free_fib_info(fi); } |
20380731b [NET]: Fix sparse... |
254 |
#ifdef CONFIG_PROC_FS |
61a026534 [NETNS]: Add name... |
255 256 |
extern int __net_init fib_proc_init(struct net *net); extern void __net_exit fib_proc_exit(struct net *net); |
cc8274f50 [IPV4]: Fix compi... |
257 258 259 260 261 262 263 264 |
#else static inline int fib_proc_init(struct net *net) { return 0; } static inline void fib_proc_exit(struct net *net) { } |
20380731b [NET]: Fix sparse... |
265 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
266 |
#endif /* _NET_FIB_H */ |