|
@@ -538,7 +538,7 @@ static void xfrm_hash_resize(struct work_struct *work)
|
|
|
|
|
|
/* Generate new index... KAME seems to generate them ordered by cost
|
|
/* Generate new index... KAME seems to generate them ordered by cost
|
|
* of an absolute inpredictability of ordering of rules. This will not pass. */
|
|
* of an absolute inpredictability of ordering of rules. This will not pass. */
|
|
-static u32 xfrm_gen_index(struct net *net, int dir)
|
|
|
|
|
|
+static u32 xfrm_gen_index(struct net *net, int dir, u32 index)
|
|
{
|
|
{
|
|
static u32 idx_generator;
|
|
static u32 idx_generator;
|
|
|
|
|
|
@@ -548,8 +548,14 @@ static u32 xfrm_gen_index(struct net *net, int dir)
|
|
u32 idx;
|
|
u32 idx;
|
|
int found;
|
|
int found;
|
|
|
|
|
|
- idx = (idx_generator | dir);
|
|
|
|
- idx_generator += 8;
|
|
|
|
|
|
+ if (!index) {
|
|
|
|
+ idx = (idx_generator | dir);
|
|
|
|
+ idx_generator += 8;
|
|
|
|
+ } else {
|
|
|
|
+ idx = index;
|
|
|
|
+ index = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (idx == 0)
|
|
if (idx == 0)
|
|
idx = 8;
|
|
idx = 8;
|
|
list = net->xfrm.policy_byidx + idx_hash(net, idx);
|
|
list = net->xfrm.policy_byidx + idx_hash(net, idx);
|
|
@@ -672,7 +678,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
|
|
xfrm_policy_requeue(delpol, policy);
|
|
xfrm_policy_requeue(delpol, policy);
|
|
__xfrm_policy_unlink(delpol, dir);
|
|
__xfrm_policy_unlink(delpol, dir);
|
|
}
|
|
}
|
|
- policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir);
|
|
|
|
|
|
+ policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir, policy->index);
|
|
hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index));
|
|
hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index));
|
|
policy->curlft.add_time = get_seconds();
|
|
policy->curlft.add_time = get_seconds();
|
|
policy->curlft.use_time = 0;
|
|
policy->curlft.use_time = 0;
|
|
@@ -1192,7 +1198,7 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
|
|
sk->sk_policy[dir] = pol;
|
|
sk->sk_policy[dir] = pol;
|
|
if (pol) {
|
|
if (pol) {
|
|
pol->curlft.add_time = get_seconds();
|
|
pol->curlft.add_time = get_seconds();
|
|
- pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir);
|
|
|
|
|
|
+ pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir, 0);
|
|
__xfrm_policy_link(pol, XFRM_POLICY_MAX+dir);
|
|
__xfrm_policy_link(pol, XFRM_POLICY_MAX+dir);
|
|
}
|
|
}
|
|
if (old_pol) {
|
|
if (old_pol) {
|