aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h82
1 files changed, 37 insertions, 45 deletions
diff --git a/include/net/route.h b/include/net/route.h
index 98705468ac03..776a27f1ab78 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -30,6 +30,7 @@
30#include <net/inet_sock.h> 30#include <net/inet_sock.h>
31#include <linux/in_route.h> 31#include <linux/in_route.h>
32#include <linux/rtnetlink.h> 32#include <linux/rtnetlink.h>
33#include <linux/rcupdate.h>
33#include <linux/route.h> 34#include <linux/route.h>
34#include <linux/ip.h> 35#include <linux/ip.h>
35#include <linux/cache.h> 36#include <linux/cache.h>
@@ -40,45 +41,41 @@
40#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) 41#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE))
41 42
42struct fib_nh; 43struct fib_nh;
43struct inet_peer;
44struct fib_info; 44struct fib_info;
45struct rtable { 45struct rtable {
46 struct dst_entry dst; 46 struct dst_entry dst;
47 47
48 /* Lookup key. */
49 __be32 rt_key_dst;
50 __be32 rt_key_src;
51
52 int rt_genid; 48 int rt_genid;
53 unsigned int rt_flags; 49 unsigned int rt_flags;
54 __u16 rt_type; 50 __u16 rt_type;
55 __u8 rt_key_tos; 51 __u16 rt_is_input;
56 52
57 __be32 rt_dst; /* Path destination */
58 __be32 rt_src; /* Path source */
59 int rt_route_iif;
60 int rt_iif; 53 int rt_iif;
61 int rt_oif;
62 __u32 rt_mark;
63 54
64 /* Info on neighbour */ 55 /* Info on neighbour */
65 __be32 rt_gateway; 56 __be32 rt_gateway;
66 57
67 /* Miscellaneous cached information */ 58 /* Miscellaneous cached information */
68 __be32 rt_spec_dst; /* RFC1122 specific destination */ 59 u32 rt_pmtu;
69 u32 rt_peer_genid; 60
70 struct inet_peer *peer; /* long-living peer info */ 61 struct list_head rt_uncached;
71 struct fib_info *fi; /* for client ref to shared metrics */
72}; 62};
73 63
74static inline bool rt_is_input_route(const struct rtable *rt) 64static inline bool rt_is_input_route(const struct rtable *rt)
75{ 65{
76 return rt->rt_route_iif != 0; 66 return rt->rt_is_input != 0;
77} 67}
78 68
79static inline bool rt_is_output_route(const struct rtable *rt) 69static inline bool rt_is_output_route(const struct rtable *rt)
80{ 70{
81 return rt->rt_route_iif == 0; 71 return rt->rt_is_input == 0;
72}
73
74static inline __be32 rt_nexthop(const struct rtable *rt, __be32 daddr)
75{
76 if (rt->rt_gateway)
77 return rt->rt_gateway;
78 return daddr;
82} 79}
83 80
84struct ip_rt_acct { 81struct ip_rt_acct {
@@ -111,10 +108,8 @@ extern struct ip_rt_acct __percpu *ip_rt_acct;
111 108
112struct in_device; 109struct in_device;
113extern int ip_rt_init(void); 110extern int ip_rt_init(void);
114extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw,
115 __be32 src, struct net_device *dev);
116extern void rt_cache_flush(struct net *net, int how); 111extern void rt_cache_flush(struct net *net, int how);
117extern void rt_cache_flush_batch(struct net *net); 112extern void rt_flush_dev(struct net_device *dev);
118extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp); 113extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp);
119extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp, 114extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
120 struct sock *sk); 115 struct sock *sk);
@@ -166,24 +161,30 @@ static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4
166 return ip_route_output_key(net, fl4); 161 return ip_route_output_key(net, fl4);
167} 162}
168 163
169extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, 164extern int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src,
170 u8 tos, struct net_device *devin, bool noref); 165 u8 tos, struct net_device *devin);
171 166
172static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, 167static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
173 u8 tos, struct net_device *devin) 168 u8 tos, struct net_device *devin)
174{ 169{
175 return ip_route_input_common(skb, dst, src, tos, devin, false); 170 int err;
176}
177 171
178static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, 172 rcu_read_lock();
179 u8 tos, struct net_device *devin) 173 err = ip_route_input_noref(skb, dst, src, tos, devin);
180{ 174 if (!err)
181 return ip_route_input_common(skb, dst, src, tos, devin, true); 175 skb_dst_force(skb);
176 rcu_read_unlock();
177
178 return err;
182} 179}
183 180
184extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, 181extern void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu,
185 unsigned short new_mtu, struct net_device *dev); 182 int oif, u32 mark, u8 protocol, int flow_flags);
186extern void ip_rt_send_redirect(struct sk_buff *skb); 183extern void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu);
184extern void ipv4_redirect(struct sk_buff *skb, struct net *net,
185 int oif, u32 mark, u8 protocol, int flow_flags);
186extern void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk);
187extern void ip_rt_send_redirect(struct sk_buff *skb);
187 188
188extern unsigned int inet_addr_type(struct net *net, __be32 addr); 189extern unsigned int inet_addr_type(struct net *net, __be32 addr);
189extern unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); 190extern unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr);
@@ -244,8 +245,6 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32
244 245
245 if (inet_sk(sk)->transparent) 246 if (inet_sk(sk)->transparent)
246 flow_flags |= FLOWI_FLAG_ANYSRC; 247 flow_flags |= FLOWI_FLAG_ANYSRC;
247 if (protocol == IPPROTO_TCP)
248 flow_flags |= FLOWI_FLAG_PRECOW_METRICS;
249 if (can_sleep) 248 if (can_sleep)
250 flow_flags |= FLOWI_FLAG_CAN_SLEEP; 249 flow_flags |= FLOWI_FLAG_CAN_SLEEP;
251 250
@@ -294,20 +293,13 @@ static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable
294 return rt; 293 return rt;
295} 294}
296 295
297extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create);
298
299static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr)
300{
301 if (rt->peer)
302 return rt->peer;
303
304 rt_bind_peer(rt, daddr, 0);
305 return rt->peer;
306}
307
308static inline int inet_iif(const struct sk_buff *skb) 296static inline int inet_iif(const struct sk_buff *skb)
309{ 297{
310 return skb_rtable(skb)->rt_iif; 298 int iif = skb_rtable(skb)->rt_iif;
299
300 if (iif)
301 return iif;
302 return skb->skb_iif;
311} 303}
312 304
313extern int sysctl_ip_default_ttl; 305extern int sysctl_ip_default_ttl;