diff options
Diffstat (limited to 'include/net/ip_fib.h')
-rw-r--r-- | include/net/ip_fib.h | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 07bdb5e9e8ac..e5d66ec88cf6 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
@@ -55,11 +55,13 @@ struct fib_nh { | |||
55 | int nh_weight; | 55 | int nh_weight; |
56 | int nh_power; | 56 | int nh_power; |
57 | #endif | 57 | #endif |
58 | #ifdef CONFIG_NET_CLS_ROUTE | 58 | #ifdef CONFIG_IP_ROUTE_CLASSID |
59 | __u32 nh_tclassid; | 59 | __u32 nh_tclassid; |
60 | #endif | 60 | #endif |
61 | int nh_oif; | 61 | int nh_oif; |
62 | __be32 nh_gw; | 62 | __be32 nh_gw; |
63 | __be32 nh_saddr; | ||
64 | int nh_saddr_genid; | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | /* | 67 | /* |
@@ -72,12 +74,13 @@ struct fib_info { | |||
72 | struct net *fib_net; | 74 | struct net *fib_net; |
73 | int fib_treeref; | 75 | int fib_treeref; |
74 | atomic_t fib_clntref; | 76 | atomic_t fib_clntref; |
75 | int fib_dead; | ||
76 | unsigned fib_flags; | 77 | unsigned fib_flags; |
77 | int fib_protocol; | 78 | unsigned char fib_dead; |
79 | unsigned char fib_protocol; | ||
80 | unsigned char fib_scope; | ||
78 | __be32 fib_prefsrc; | 81 | __be32 fib_prefsrc; |
79 | u32 fib_priority; | 82 | u32 fib_priority; |
80 | u32 fib_metrics[RTAX_MAX]; | 83 | u32 *fib_metrics; |
81 | #define fib_mtu fib_metrics[RTAX_MTU-1] | 84 | #define fib_mtu fib_metrics[RTAX_MTU-1] |
82 | #define fib_window fib_metrics[RTAX_WINDOW-1] | 85 | #define fib_window fib_metrics[RTAX_WINDOW-1] |
83 | #define fib_rtt fib_metrics[RTAX_RTT-1] | 86 | #define fib_rtt fib_metrics[RTAX_RTT-1] |
@@ -96,12 +99,15 @@ struct fib_info { | |||
96 | struct fib_rule; | 99 | struct fib_rule; |
97 | #endif | 100 | #endif |
98 | 101 | ||
102 | struct fib_table; | ||
99 | struct fib_result { | 103 | struct fib_result { |
100 | unsigned char prefixlen; | 104 | unsigned char prefixlen; |
101 | unsigned char nh_sel; | 105 | unsigned char nh_sel; |
102 | unsigned char type; | 106 | unsigned char type; |
103 | unsigned char scope; | 107 | unsigned char scope; |
104 | struct fib_info *fi; | 108 | struct fib_info *fi; |
109 | struct fib_table *table; | ||
110 | struct list_head *fa_head; | ||
105 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 111 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
106 | struct fib_rule *r; | 112 | struct fib_rule *r; |
107 | #endif | 113 | #endif |
@@ -136,11 +142,20 @@ struct fib_result_nl { | |||
136 | 142 | ||
137 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ | 143 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
138 | 144 | ||
139 | #define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) | 145 | extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh); |
146 | |||
147 | #define FIB_RES_SADDR(net, res) \ | ||
148 | ((FIB_RES_NH(res).nh_saddr_genid == \ | ||
149 | atomic_read(&(net)->ipv4.dev_addr_genid)) ? \ | ||
150 | FIB_RES_NH(res).nh_saddr : \ | ||
151 | fib_info_update_nh_saddr((net), &FIB_RES_NH(res))) | ||
140 | #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) | 152 | #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) |
141 | #define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) | 153 | #define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) |
142 | #define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) | 154 | #define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) |
143 | 155 | ||
156 | #define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \ | ||
157 | FIB_RES_SADDR(net, res)) | ||
158 | |||
144 | struct fib_table { | 159 | struct fib_table { |
145 | struct hlist_node tb_hlist; | 160 | struct hlist_node tb_hlist; |
146 | u32 tb_id; | 161 | u32 tb_id; |
@@ -148,16 +163,13 @@ struct fib_table { | |||
148 | unsigned char tb_data[0]; | 163 | unsigned char tb_data[0]; |
149 | }; | 164 | }; |
150 | 165 | ||
151 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, | 166 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, |
152 | struct fib_result *res, int fib_flags); | 167 | struct fib_result *res, int fib_flags); |
153 | extern int fib_table_insert(struct fib_table *, struct fib_config *); | 168 | extern int fib_table_insert(struct fib_table *, struct fib_config *); |
154 | extern int fib_table_delete(struct fib_table *, struct fib_config *); | 169 | extern int fib_table_delete(struct fib_table *, struct fib_config *); |
155 | extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, | 170 | extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, |
156 | struct netlink_callback *cb); | 171 | struct netlink_callback *cb); |
157 | extern int fib_table_flush(struct fib_table *table); | 172 | extern int fib_table_flush(struct fib_table *table); |
158 | extern void fib_table_select_default(struct fib_table *table, | ||
159 | const struct flowi *flp, | ||
160 | struct fib_result *res); | ||
161 | extern void fib_free_table(struct fib_table *tb); | 173 | extern void fib_free_table(struct fib_table *tb); |
162 | 174 | ||
163 | 175 | ||
@@ -182,7 +194,7 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id) | |||
182 | return fib_get_table(net, id); | 194 | return fib_get_table(net, id); |
183 | } | 195 | } |
184 | 196 | ||
185 | static inline int fib_lookup(struct net *net, const struct flowi *flp, | 197 | static inline int fib_lookup(struct net *net, const struct flowi4 *flp, |
186 | struct fib_result *res) | 198 | struct fib_result *res) |
187 | { | 199 | { |
188 | struct fib_table *table; | 200 | struct fib_table *table; |
@@ -201,11 +213,11 @@ static inline int fib_lookup(struct net *net, const struct flowi *flp, | |||
201 | extern int __net_init fib4_rules_init(struct net *net); | 213 | extern int __net_init fib4_rules_init(struct net *net); |
202 | extern void __net_exit fib4_rules_exit(struct net *net); | 214 | extern void __net_exit fib4_rules_exit(struct net *net); |
203 | 215 | ||
204 | #ifdef CONFIG_NET_CLS_ROUTE | 216 | #ifdef CONFIG_IP_ROUTE_CLASSID |
205 | extern u32 fib_rules_tclass(struct fib_result *res); | 217 | extern u32 fib_rules_tclass(const struct fib_result *res); |
206 | #endif | 218 | #endif |
207 | 219 | ||
208 | extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); | 220 | extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res); |
209 | 221 | ||
210 | extern struct fib_table *fib_new_table(struct net *net, u32 id); | 222 | extern struct fib_table *fib_new_table(struct net *net, u32 id); |
211 | extern struct fib_table *fib_get_table(struct net *net, u32 id); | 223 | extern struct fib_table *fib_get_table(struct net *net, u32 id); |
@@ -218,24 +230,23 @@ extern void ip_fib_init(void); | |||
218 | extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, | 230 | extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, |
219 | struct net_device *dev, __be32 *spec_dst, | 231 | struct net_device *dev, __be32 *spec_dst, |
220 | u32 *itag, u32 mark); | 232 | u32 *itag, u32 mark); |
221 | extern void fib_select_default(struct net *net, const struct flowi *flp, | 233 | extern void fib_select_default(struct fib_result *res); |
222 | struct fib_result *res); | ||
223 | 234 | ||
224 | /* Exported by fib_semantics.c */ | 235 | /* Exported by fib_semantics.c */ |
225 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); | 236 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); |
226 | extern int fib_sync_down_dev(struct net_device *dev, int force); | 237 | extern int fib_sync_down_dev(struct net_device *dev, int force); |
227 | extern int fib_sync_down_addr(struct net *net, __be32 local); | 238 | extern int fib_sync_down_addr(struct net *net, __be32 local); |
239 | extern void fib_update_nh_saddrs(struct net_device *dev); | ||
228 | extern int fib_sync_up(struct net_device *dev); | 240 | extern int fib_sync_up(struct net_device *dev); |
229 | extern __be32 __fib_res_prefsrc(struct fib_result *res); | 241 | extern void fib_select_multipath(struct fib_result *res); |
230 | extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); | ||
231 | 242 | ||
232 | /* Exported by fib_{hash|trie}.c */ | 243 | /* Exported by fib_trie.c */ |
233 | extern void fib_hash_init(void); | 244 | extern void fib_trie_init(void); |
234 | extern struct fib_table *fib_hash_table(u32 id); | 245 | extern struct fib_table *fib_trie_table(u32 id); |
235 | 246 | ||
236 | static inline void fib_combine_itag(u32 *itag, struct fib_result *res) | 247 | static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) |
237 | { | 248 | { |
238 | #ifdef CONFIG_NET_CLS_ROUTE | 249 | #ifdef CONFIG_IP_ROUTE_CLASSID |
239 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 250 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
240 | u32 rtag; | 251 | u32 rtag; |
241 | #endif | 252 | #endif |