aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-11-30 15:27:11 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-30 15:27:11 -0500
commitb3419363808f2481b24a817f491878e1795db4c7 (patch)
tree76cfa3c55d6798a9bf25d200778dc212841f6cb0
parent672f007d65f50468a4a1e55825fe58e5b035324d (diff)
ipv6: Add infrastructure to bind inet_peer objects to routes.
They are only allowed on cached ipv6 routes. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip6_fib.h2
-rw-r--r--include/net/ip6_route.h3
-rw-r--r--net/ipv4/inetpeer.c2
-rw-r--r--net/ipv6/route.c18
4 files changed, 25 insertions, 0 deletions
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 062a823d311c..708ff7cb8806 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -21,6 +21,7 @@
21#include <net/dst.h> 21#include <net/dst.h>
22#include <net/flow.h> 22#include <net/flow.h>
23#include <net/netlink.h> 23#include <net/netlink.h>
24#include <net/inetpeer.h>
24 25
25#ifdef CONFIG_IPV6_MULTIPLE_TABLES 26#ifdef CONFIG_IPV6_MULTIPLE_TABLES
26#define FIB6_TABLE_HASHSZ 256 27#define FIB6_TABLE_HASHSZ 256
@@ -109,6 +110,7 @@ struct rt6_info {
109 u32 rt6i_metric; 110 u32 rt6i_metric;
110 111
111 struct inet6_dev *rt6i_idev; 112 struct inet6_dev *rt6i_idev;
113 struct inet_peer *rt6i_peer;
112 114
113#ifdef CONFIG_XFRM 115#ifdef CONFIG_XFRM
114 u32 rt6i_flow_cache_genid; 116 u32 rt6i_flow_cache_genid;
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 278312c95f96..23fed28db4bb 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -56,6 +56,9 @@ static inline unsigned int rt6_flags2srcprefs(int flags)
56 return (flags >> 3) & 7; 56 return (flags >> 3) & 7;
57} 57}
58 58
59extern void rt6_bind_peer(struct rt6_info *rt,
60 int create);
61
59extern void ip6_route_input(struct sk_buff *skb); 62extern void ip6_route_input(struct sk_buff *skb);
60 63
61extern struct dst_entry * ip6_route_output(struct net *net, 64extern struct dst_entry * ip6_route_output(struct net *net,
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 1c1335b0d401..f95b89f3916d 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -532,6 +532,7 @@ static int compute_total(void)
532{ 532{
533 return v4_peers.total + v6_peers.total; 533 return v4_peers.total + v6_peers.total;
534} 534}
535EXPORT_SYMBOL_GPL(inet_getpeer);
535 536
536/* Called with local BH disabled. */ 537/* Called with local BH disabled. */
537static void peer_check_expire(unsigned long dummy) 538static void peer_check_expire(unsigned long dummy)
@@ -577,3 +578,4 @@ void inet_putpeer(struct inet_peer *p)
577 578
578 local_bh_enable(); 579 local_bh_enable();
579} 580}
581EXPORT_SYMBOL_GPL(inet_putpeer);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a0c4ad109c63..026caef0326c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -188,11 +188,29 @@ static void ip6_dst_destroy(struct dst_entry *dst)
188{ 188{
189 struct rt6_info *rt = (struct rt6_info *)dst; 189 struct rt6_info *rt = (struct rt6_info *)dst;
190 struct inet6_dev *idev = rt->rt6i_idev; 190 struct inet6_dev *idev = rt->rt6i_idev;
191 struct inet_peer *peer = rt->rt6i_peer;
191 192
192 if (idev != NULL) { 193 if (idev != NULL) {
193 rt->rt6i_idev = NULL; 194 rt->rt6i_idev = NULL;
194 in6_dev_put(idev); 195 in6_dev_put(idev);
195 } 196 }
197 if (peer) {
198 BUG_ON(!(rt->rt6i_flags & RTF_CACHE));
199 rt->rt6i_peer = NULL;
200 inet_putpeer(peer);
201 }
202}
203
204void rt6_bind_peer(struct rt6_info *rt, int create)
205{
206 struct inet_peer *peer;
207
208 if (WARN_ON(!(rt->rt6i_flags & RTF_CACHE)))
209 return;
210
211 peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create);
212 if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL)
213 inet_putpeer(peer);
196} 214}
197 215
198static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, 216static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,