提交 b3419363 编写于 作者: D David S. Miller

ipv6: Add infrastructure to bind inet_peer objects to routes.

They are only allowed on cached ipv6 routes.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 672f007d
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <net/dst.h> #include <net/dst.h>
#include <net/flow.h> #include <net/flow.h>
#include <net/netlink.h> #include <net/netlink.h>
#include <net/inetpeer.h>
#ifdef CONFIG_IPV6_MULTIPLE_TABLES #ifdef CONFIG_IPV6_MULTIPLE_TABLES
#define FIB6_TABLE_HASHSZ 256 #define FIB6_TABLE_HASHSZ 256
...@@ -109,6 +110,7 @@ struct rt6_info { ...@@ -109,6 +110,7 @@ struct rt6_info {
u32 rt6i_metric; u32 rt6i_metric;
struct inet6_dev *rt6i_idev; struct inet6_dev *rt6i_idev;
struct inet_peer *rt6i_peer;
#ifdef CONFIG_XFRM #ifdef CONFIG_XFRM
u32 rt6i_flow_cache_genid; u32 rt6i_flow_cache_genid;
......
...@@ -56,6 +56,9 @@ static inline unsigned int rt6_flags2srcprefs(int flags) ...@@ -56,6 +56,9 @@ static inline unsigned int rt6_flags2srcprefs(int flags)
return (flags >> 3) & 7; return (flags >> 3) & 7;
} }
extern void rt6_bind_peer(struct rt6_info *rt,
int create);
extern void ip6_route_input(struct sk_buff *skb); extern void ip6_route_input(struct sk_buff *skb);
extern struct dst_entry * ip6_route_output(struct net *net, extern struct dst_entry * ip6_route_output(struct net *net,
......
...@@ -532,6 +532,7 @@ static int compute_total(void) ...@@ -532,6 +532,7 @@ static int compute_total(void)
{ {
return v4_peers.total + v6_peers.total; return v4_peers.total + v6_peers.total;
} }
EXPORT_SYMBOL_GPL(inet_getpeer);
/* Called with local BH disabled. */ /* Called with local BH disabled. */
static void peer_check_expire(unsigned long dummy) static void peer_check_expire(unsigned long dummy)
...@@ -577,3 +578,4 @@ void inet_putpeer(struct inet_peer *p) ...@@ -577,3 +578,4 @@ void inet_putpeer(struct inet_peer *p)
local_bh_enable(); local_bh_enable();
} }
EXPORT_SYMBOL_GPL(inet_putpeer);
...@@ -188,11 +188,29 @@ static void ip6_dst_destroy(struct dst_entry *dst) ...@@ -188,11 +188,29 @@ static void ip6_dst_destroy(struct dst_entry *dst)
{ {
struct rt6_info *rt = (struct rt6_info *)dst; struct rt6_info *rt = (struct rt6_info *)dst;
struct inet6_dev *idev = rt->rt6i_idev; struct inet6_dev *idev = rt->rt6i_idev;
struct inet_peer *peer = rt->rt6i_peer;
if (idev != NULL) { if (idev != NULL) {
rt->rt6i_idev = NULL; rt->rt6i_idev = NULL;
in6_dev_put(idev); in6_dev_put(idev);
} }
if (peer) {
BUG_ON(!(rt->rt6i_flags & RTF_CACHE));
rt->rt6i_peer = NULL;
inet_putpeer(peer);
}
}
void rt6_bind_peer(struct rt6_info *rt, int create)
{
struct inet_peer *peer;
if (WARN_ON(!(rt->rt6i_flags & RTF_CACHE)))
return;
peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create);
if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL)
inet_putpeer(peer);
} }
static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册