aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_fib.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/ip_fib.h')
-rw-r--r--include/net/ip_fib.h55
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 {
96struct fib_rule; 99struct fib_rule;
97#endif 100#endif
98 101
102struct fib_table;
99struct fib_result { 103struct 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)) 145extern __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
144struct fib_table { 159struct 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
151extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, 166extern 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);
153extern int fib_table_insert(struct fib_table *, struct fib_config *); 168extern int fib_table_insert(struct fib_table *, struct fib_config *);
154extern int fib_table_delete(struct fib_table *, struct fib_config *); 169extern int fib_table_delete(struct fib_table *, struct fib_config *);
155extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, 170extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
156 struct netlink_callback *cb); 171 struct netlink_callback *cb);
157extern int fib_table_flush(struct fib_table *table); 172extern int fib_table_flush(struct fib_table *table);
158extern void fib_table_select_default(struct fib_table *table,
159 const struct flowi *flp,
160 struct fib_result *res);
161extern void fib_free_table(struct fib_table *tb); 173extern 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
185static inline int fib_lookup(struct net *net, const struct flowi *flp, 197static 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,
201extern int __net_init fib4_rules_init(struct net *net); 213extern int __net_init fib4_rules_init(struct net *net);
202extern void __net_exit fib4_rules_exit(struct net *net); 214extern void __net_exit fib4_rules_exit(struct net *net);
203 215
204#ifdef CONFIG_NET_CLS_ROUTE 216#ifdef CONFIG_IP_ROUTE_CLASSID
205extern u32 fib_rules_tclass(struct fib_result *res); 217extern u32 fib_rules_tclass(const struct fib_result *res);
206#endif 218#endif
207 219
208extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); 220extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res);
209 221
210extern struct fib_table *fib_new_table(struct net *net, u32 id); 222extern struct fib_table *fib_new_table(struct net *net, u32 id);
211extern struct fib_table *fib_get_table(struct net *net, u32 id); 223extern struct fib_table *fib_get_table(struct net *net, u32 id);
@@ -218,24 +230,23 @@ extern void ip_fib_init(void);
218extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, 230extern 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);
221extern void fib_select_default(struct net *net, const struct flowi *flp, 233extern 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 */
225extern int ip_fib_check_default(__be32 gw, struct net_device *dev); 236extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
226extern int fib_sync_down_dev(struct net_device *dev, int force); 237extern int fib_sync_down_dev(struct net_device *dev, int force);
227extern int fib_sync_down_addr(struct net *net, __be32 local); 238extern int fib_sync_down_addr(struct net *net, __be32 local);
239extern void fib_update_nh_saddrs(struct net_device *dev);
228extern int fib_sync_up(struct net_device *dev); 240extern int fib_sync_up(struct net_device *dev);
229extern __be32 __fib_res_prefsrc(struct fib_result *res); 241extern void fib_select_multipath(struct fib_result *res);
230extern 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 */
233extern void fib_hash_init(void); 244extern void fib_trie_init(void);
234extern struct fib_table *fib_hash_table(u32 id); 245extern struct fib_table *fib_trie_table(u32 id);
235 246
236static inline void fib_combine_itag(u32 *itag, struct fib_result *res) 247static 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