aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-10 01:36:36 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-11 05:08:47 -0400
commit97bab73f987e2781129cd6f4b6379bf44d808cc6 (patch)
tree40b10c4c021c8b5524c19f79fcfe4b0799b59952 /include/net/route.h
parentc0efc887dcadbdbfe171f028acfab9c7c00e9dde (diff)
inet: Hide route peer accesses behind helpers.
We encode the pointer(s) into an unsigned long with one state bit. The state bit is used so we can store the inetpeer tree root to use when resolving the peer later. Later the peer roots will be per-FIB table, and this change works to facilitate that. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h42
1 files changed, 38 insertions, 4 deletions
diff --git a/include/net/route.h b/include/net/route.h
index 433fc6c1d404..6340c37677fc 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -67,10 +67,44 @@ struct rtable {
67 /* Miscellaneous cached information */ 67 /* Miscellaneous cached information */
68 __be32 rt_spec_dst; /* RFC1122 specific destination */ 68 __be32 rt_spec_dst; /* RFC1122 specific destination */
69 u32 rt_peer_genid; 69 u32 rt_peer_genid;
70 struct inet_peer *peer; /* long-living peer info */ 70 unsigned long _peer; /* long-living peer info */
71 struct fib_info *fi; /* for client ref to shared metrics */ 71 struct fib_info *fi; /* for client ref to shared metrics */
72}; 72};
73 73
74static inline struct inet_peer *rt_peer_ptr(struct rtable *rt)
75{
76 return inetpeer_ptr(rt->_peer);
77}
78
79static inline bool rt_has_peer(struct rtable *rt)
80{
81 return inetpeer_ptr_is_peer(rt->_peer);
82}
83
84static inline void __rt_set_peer(struct rtable *rt, struct inet_peer *peer)
85{
86 __inetpeer_ptr_set_peer(&rt->_peer, peer);
87}
88
89static inline bool rt_set_peer(struct rtable *rt, struct inet_peer *peer)
90{
91 return inetpeer_ptr_set_peer(&rt->_peer, peer);
92}
93
94static inline void rt_init_peer(struct rtable *rt, struct inet_peer_base *base)
95{
96 inetpeer_init_ptr(&rt->_peer, base);
97}
98
99static inline void rt_transfer_peer(struct rtable *rt, struct rtable *ort)
100{
101 rt->_peer = ort->_peer;
102 if (rt_has_peer(ort)) {
103 struct inet_peer *peer = rt_peer_ptr(ort);
104 atomic_inc(&peer->refcnt);
105 }
106}
107
74static inline bool rt_is_input_route(const struct rtable *rt) 108static inline bool rt_is_input_route(const struct rtable *rt)
75{ 109{
76 return rt->rt_route_iif != 0; 110 return rt->rt_route_iif != 0;
@@ -298,11 +332,11 @@ extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create);
298 332
299static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, int create) 333static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, int create)
300{ 334{
301 if (rt->peer) 335 if (rt_has_peer(rt))
302 return rt->peer; 336 return rt_peer_ptr(rt);
303 337
304 rt_bind_peer(rt, daddr, create); 338 rt_bind_peer(rt, daddr, create);
305 return rt->peer; 339 return rt_peer_ptr(rt);
306} 340}
307 341
308static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr) 342static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr)