aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-19 15:31:33 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-20 16:31:21 -0400
commitf5b0a8743601a4477419171f5046bd07d1c080a0 (patch)
tree92e17ec293c3d0e35a0deda5d3bbf43710fb96ff /net/xfrm
parentf8126f1d5136be1ca1a3536d43ad7a710b5620f8 (diff)
net: Document dst->obsolete better.
Add a big comment explaining how the field works, and use defines instead of magic constants for the values assigned to it. Suggested by Joe Perches. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_policy.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 65bd1ca51517..c5a5165a5927 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1350,7 +1350,7 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family)
1350 default: 1350 default:
1351 BUG(); 1351 BUG();
1352 } 1352 }
1353 xdst = dst_alloc(dst_ops, NULL, 0, 0, 0); 1353 xdst = dst_alloc(dst_ops, NULL, 0, DST_OBSOLETE_NONE, 0);
1354 1354
1355 if (likely(xdst)) { 1355 if (likely(xdst)) {
1356 struct dst_entry *dst = &xdst->u.dst; 1356 struct dst_entry *dst = &xdst->u.dst;
@@ -1477,7 +1477,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
1477 dst1->xfrm = xfrm[i]; 1477 dst1->xfrm = xfrm[i];
1478 xdst->xfrm_genid = xfrm[i]->genid; 1478 xdst->xfrm_genid = xfrm[i]->genid;
1479 1479
1480 dst1->obsolete = -1; 1480 dst1->obsolete = DST_OBSOLETE_FORCE_CHK;
1481 dst1->flags |= DST_HOST; 1481 dst1->flags |= DST_HOST;
1482 dst1->lastuse = now; 1482 dst1->lastuse = now;
1483 1483
@@ -2219,12 +2219,13 @@ EXPORT_SYMBOL(__xfrm_route_forward);
2219static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie) 2219static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie)
2220{ 2220{
2221 /* Code (such as __xfrm4_bundle_create()) sets dst->obsolete 2221 /* Code (such as __xfrm4_bundle_create()) sets dst->obsolete
2222 * to "-1" to force all XFRM destinations to get validated by 2222 * to DST_OBSOLETE_FORCE_CHK to force all XFRM destinations to
2223 * dst_ops->check on every use. We do this because when a 2223 * get validated by dst_ops->check on every use. We do this
2224 * normal route referenced by an XFRM dst is obsoleted we do 2224 * because when a normal route referenced by an XFRM dst is
2225 * not go looking around for all parent referencing XFRM dsts 2225 * obsoleted we do not go looking around for all parent
2226 * so that we can invalidate them. It is just too much work. 2226 * referencing XFRM dsts so that we can invalidate them. It
2227 * Instead we make the checks here on every use. For example: 2227 * is just too much work. Instead we make the checks here on
2228 * every use. For example:
2228 * 2229 *
2229 * XFRM dst A --> IPv4 dst X 2230 * XFRM dst A --> IPv4 dst X
2230 * 2231 *
@@ -2234,9 +2235,9 @@ static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie)
2234 * stale_bundle() check. 2235 * stale_bundle() check.
2235 * 2236 *
2236 * When a policy's bundle is pruned, we dst_free() the XFRM 2237 * When a policy's bundle is pruned, we dst_free() the XFRM
2237 * dst which causes it's ->obsolete field to be set to a 2238 * dst which causes it's ->obsolete field to be set to
2238 * positive non-zero integer. If an XFRM dst has been pruned 2239 * DST_OBSOLETE_DEAD. If an XFRM dst has been pruned like
2239 * like this, we want to force a new route lookup. 2240 * this, we want to force a new route lookup.
2240 */ 2241 */
2241 if (dst->obsolete < 0 && !stale_bundle(dst)) 2242 if (dst->obsolete < 0 && !stale_bundle(dst))
2242 return dst; 2243 return dst;