aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-02-07 23:38:06 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-10 16:33:41 -0500
commit6431cbc25fa21635ee04eb0516ba6c51389fbfac (patch)
tree515deede7292fce41c019e7bd72b58cab34ecb9c /net/ipv6
parentddd4aa424b866a08ceba7ddf38e61542c91b93a0 (diff)
inet: Create a mechanism for upward inetpeer propagation into routes.
If we didn't have a routing cache, we would not be able to properly propagate certain kinds of dynamic path attributes, for example PMTU information and redirects. The reason is that if we didn't have a routing cache, then there would be no way to lookup all of the active cached routes hanging off of sockets, tunnels, IPSEC bundles, etc. Consider the case where we created a cached route, but no inetpeer entry existed and also we were not asked to pre-COW the route metrics and therefore did not force the creation a new inetpeer entry. If we later get a PMTU message, or a redirect, and store this information in a new inetpeer entry, there is no way to teach that cached route about the newly existing inetpeer entry. The facilities implemented here handle this problem. First we create a generation ID. When we create a cached route of any kind, we remember the generation ID at the time of attachment. Any time we force-create an inetpeer entry in response to new path information, we bump that generation ID. The dst_ops->check() callback is where the knowledge of this event is propagated. If the global generation ID does not equal the one stored in the cached route, and the cached route has not attached to an inetpeer yet, we look it up and attach if one is found. Now that we've updated the cached route's information, we update the route's generation ID too. This clears the way for implementing PMTU and redirects directly in the inetpeer cache. There is absolutely no need to consult cached route information in order to maintain this information. At this point nothing bumps the inetpeer genids, that comes in the later changes which handle PMTUs and redirects using inetpeers. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/route.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 12ec83d48806..ad8556e6fd41 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -240,6 +240,13 @@ static void ip6_dst_destroy(struct dst_entry *dst)
240 } 240 }
241} 241}
242 242
243static atomic_t __rt6_peer_genid = ATOMIC_INIT(0);
244
245static u32 rt6_peer_genid(void)
246{
247 return atomic_read(&__rt6_peer_genid);
248}
249
243void rt6_bind_peer(struct rt6_info *rt, int create) 250void rt6_bind_peer(struct rt6_info *rt, int create)
244{ 251{
245 struct inet_peer *peer; 252 struct inet_peer *peer;
@@ -247,6 +254,8 @@ void rt6_bind_peer(struct rt6_info *rt, int create)
247 peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create); 254 peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create);
248 if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL) 255 if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL)
249 inet_putpeer(peer); 256 inet_putpeer(peer);
257 else
258 rt->rt6i_peer_genid = rt6_peer_genid();
250} 259}
251 260
252static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, 261static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -912,9 +921,14 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
912 921
913 rt = (struct rt6_info *) dst; 922 rt = (struct rt6_info *) dst;
914 923
915 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) 924 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) {
925 if (rt->rt6i_peer_genid != rt6_peer_genid()) {
926 if (!rt->rt6i_peer)
927 rt6_bind_peer(rt, 0);
928 rt->rt6i_peer_genid = rt6_peer_genid();
929 }
916 return dst; 930 return dst;
917 931 }
918 return NULL; 932 return NULL;
919} 933}
920 934