[XFRM]: Fix aevent timer.
Send aevent immediately if we have sent nothing since last timer and this is the first packet. Fixes a corner case when packet threshold is very high, the timer low and a very low packet rate input which is bursty. Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
6c97e72a16
commit
2717096ab4
@@ -143,6 +143,11 @@ struct xfrm_state
|
|||||||
/* Replay detection state at the time we sent the last notification */
|
/* Replay detection state at the time we sent the last notification */
|
||||||
struct xfrm_replay_state preplay;
|
struct xfrm_replay_state preplay;
|
||||||
|
|
||||||
|
/* internal flag that only holds state for delayed aevent at the
|
||||||
|
* moment
|
||||||
|
*/
|
||||||
|
u32 xflags;
|
||||||
|
|
||||||
/* Replay detection notification settings */
|
/* Replay detection notification settings */
|
||||||
u32 replay_maxage;
|
u32 replay_maxage;
|
||||||
u32 replay_maxdiff;
|
u32 replay_maxdiff;
|
||||||
@@ -168,6 +173,9 @@ struct xfrm_state
|
|||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* xflags - make enum if more show up */
|
||||||
|
#define XFRM_TIME_DEFER 1
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
XFRM_STATE_VOID,
|
XFRM_STATE_VOID,
|
||||||
XFRM_STATE_ACQ,
|
XFRM_STATE_ACQ,
|
||||||
|
@@ -805,16 +805,22 @@ void xfrm_replay_notify(struct xfrm_state *x, int event)
|
|||||||
case XFRM_REPLAY_UPDATE:
|
case XFRM_REPLAY_UPDATE:
|
||||||
if (x->replay_maxdiff &&
|
if (x->replay_maxdiff &&
|
||||||
(x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
|
(x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
|
||||||
(x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))
|
(x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
|
||||||
return;
|
if (x->xflags & XFRM_TIME_DEFER)
|
||||||
|
event = XFRM_REPLAY_TIMEOUT;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFRM_REPLAY_TIMEOUT:
|
case XFRM_REPLAY_TIMEOUT:
|
||||||
if ((x->replay.seq == x->preplay.seq) &&
|
if ((x->replay.seq == x->preplay.seq) &&
|
||||||
(x->replay.bitmap == x->preplay.bitmap) &&
|
(x->replay.bitmap == x->preplay.bitmap) &&
|
||||||
(x->replay.oseq == x->preplay.oseq))
|
(x->replay.oseq == x->preplay.oseq)) {
|
||||||
|
x->xflags |= XFRM_TIME_DEFER;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -825,8 +831,10 @@ void xfrm_replay_notify(struct xfrm_state *x, int event)
|
|||||||
km_state_notify(x, &c);
|
km_state_notify(x, &c);
|
||||||
|
|
||||||
if (x->replay_maxage &&
|
if (x->replay_maxage &&
|
||||||
!mod_timer(&x->rtimer, jiffies + x->replay_maxage))
|
!mod_timer(&x->rtimer, jiffies + x->replay_maxage)) {
|
||||||
xfrm_state_hold(x);
|
xfrm_state_hold(x);
|
||||||
|
x->xflags &= ~XFRM_TIME_DEFER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(xfrm_replay_notify);
|
EXPORT_SYMBOL(xfrm_replay_notify);
|
||||||
|
|
||||||
@@ -836,10 +844,15 @@ static void xfrm_replay_timer_handler(unsigned long data)
|
|||||||
|
|
||||||
spin_lock(&x->lock);
|
spin_lock(&x->lock);
|
||||||
|
|
||||||
if (xfrm_aevent_is_on() && x->km.state == XFRM_STATE_VALID)
|
if (x->km.state == XFRM_STATE_VALID) {
|
||||||
xfrm_replay_notify(x, XFRM_REPLAY_TIMEOUT);
|
if (xfrm_aevent_is_on())
|
||||||
|
xfrm_replay_notify(x, XFRM_REPLAY_TIMEOUT);
|
||||||
|
else
|
||||||
|
x->xflags |= XFRM_TIME_DEFER;
|
||||||
|
}
|
||||||
|
|
||||||
spin_unlock(&x->lock);
|
spin_unlock(&x->lock);
|
||||||
|
xfrm_state_put(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xfrm_replay_check(struct xfrm_state *x, u32 seq)
|
int xfrm_replay_check(struct xfrm_state *x, u32 seq)
|
||||||
|
Reference in New Issue
Block a user