aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/xfrm.h3
-rw-r--r--net/ipv4/xfrm4_policy.c1
-rw-r--r--net/ipv6/xfrm6_policy.c1
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--net/xfrm/xfrm_state.c3
5 files changed, 10 insertions, 0 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 3405e5d9d51c..fd4a300b5baf 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -104,6 +104,8 @@ struct xfrm_state
104 struct xfrm_id id; 104 struct xfrm_id id;
105 struct xfrm_selector sel; 105 struct xfrm_selector sel;
106 106
107 u32 genid;
108
107 /* Key manger bits */ 109 /* Key manger bits */
108 struct { 110 struct {
109 u8 state; 111 u8 state;
@@ -590,6 +592,7 @@ struct xfrm_dst
590 struct rt6_info rt6; 592 struct rt6_info rt6;
591 } u; 593 } u;
592 struct dst_entry *route; 594 struct dst_entry *route;
595 u32 genid;
593 u32 route_mtu_cached; 596 u32 route_mtu_cached;
594 u32 child_mtu_cached; 597 u32 child_mtu_cached;
595 u32 route_cookie; 598 u32 route_cookie;
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 42d8ded0f96a..479598566f1d 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -93,6 +93,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
93 93
94 xdst = (struct xfrm_dst *)dst1; 94 xdst = (struct xfrm_dst *)dst1;
95 xdst->route = &rt->u.dst; 95 xdst->route = &rt->u.dst;
96 xdst->genid = xfrm[i]->genid;
96 97
97 dst1->next = dst_prev; 98 dst1->next = dst_prev;
98 dst_prev = dst1; 99 dst_prev = dst1;
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 98c2fe449b3f..9391c4c94feb 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -149,6 +149,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
149 149
150 xdst = (struct xfrm_dst *)dst1; 150 xdst = (struct xfrm_dst *)dst1;
151 xdst->route = &rt->u.dst; 151 xdst->route = &rt->u.dst;
152 xdst->genid = xfrm[i]->genid;
152 if (rt->rt6i_node) 153 if (rt->rt6i_node)
153 xdst->route_cookie = rt->rt6i_node->fn_sernum; 154 xdst->route_cookie = rt->rt6i_node->fn_sernum;
154 155
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 1732159ffd01..7fc6944ee36f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1536,6 +1536,8 @@ int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family, int str
1536 return 0; 1536 return 0;
1537 if (dst->xfrm->km.state != XFRM_STATE_VALID) 1537 if (dst->xfrm->km.state != XFRM_STATE_VALID)
1538 return 0; 1538 return 0;
1539 if (xdst->genid != dst->xfrm->genid)
1540 return 0;
1539 1541
1540 if (strict && fl && dst->xfrm->props.mode != XFRM_MODE_TUNNEL && 1542 if (strict && fl && dst->xfrm->props.mode != XFRM_MODE_TUNNEL &&
1541 !xfrm_state_addr_flow_check(dst->xfrm, fl, family)) 1543 !xfrm_state_addr_flow_check(dst->xfrm, fl, family))
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 445263c54c94..535d43c14720 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -53,6 +53,7 @@ static struct hlist_head *xfrm_state_byspi __read_mostly;
53static unsigned int xfrm_state_hmask __read_mostly; 53static unsigned int xfrm_state_hmask __read_mostly;
54static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024; 54static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024;
55static unsigned int xfrm_state_num; 55static unsigned int xfrm_state_num;
56static unsigned int xfrm_state_genid;
56 57
57static inline unsigned int __xfrm4_dst_hash(xfrm_address_t *addr, unsigned int hmask) 58static inline unsigned int __xfrm4_dst_hash(xfrm_address_t *addr, unsigned int hmask)
58{ 59{
@@ -745,6 +746,8 @@ static void __xfrm_state_insert(struct xfrm_state *x)
745{ 746{
746 unsigned int h = xfrm_dst_hash(&x->id.daddr, x->props.family); 747 unsigned int h = xfrm_dst_hash(&x->id.daddr, x->props.family);
747 748
749 x->genid = ++xfrm_state_genid;
750
748 hlist_add_head(&x->bydst, xfrm_state_bydst+h); 751 hlist_add_head(&x->bydst, xfrm_state_bydst+h);
749 xfrm_state_hold(x); 752 xfrm_state_hold(x);
750 753