Skip to content

Commit c05c5e5

Browse files
Jianbo Liuklassert
authored andcommitted
xfrm: replay: Fix the update of replay_esn->oseq_hi for GSO
When skb needs GSO and wrap around happens, if xo->seq.low (seqno of the first skb segment) is before the last seq number but oseq (seqno of the last segment) is after it, xo->seq.low is still bigger than replay_esn->oseq while oseq is smaller than it, so the update of replay_esn->oseq_hi is missed for this case wrap around because of the change in the cited commit. For example, if sending a packet with gso_segs=3 while old replay_esn->oseq=0xfffffffe, we calculate: xo->seq.low = 0xfffffffe + 1 = 0x0xffffffff oseq = 0xfffffffe + 3 = 0x1 (oseq < replay_esn->oseq) is true, but (xo->seq.low < replay_esn->oseq) is false, so replay_esn->oseq_hi is not incremented. To fix this issue, change the outer checking back for the update of replay_esn->oseq_hi. And add new checking inside for the update of packet's oseq_hi. Fixes: 4b549cc ("xfrm: replay: Fix ESN wrap around for GSO") Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Patrisious Haddad <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 9bb88c6 commit c05c5e5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

net/xfrm/xfrm_replay.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,12 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
714714
oseq += skb_shinfo(skb)->gso_segs;
715715
}
716716

717-
if (unlikely(xo->seq.low < replay_esn->oseq)) {
718-
XFRM_SKB_CB(skb)->seq.output.hi = ++oseq_hi;
719-
xo->seq.hi = oseq_hi;
720-
replay_esn->oseq_hi = oseq_hi;
717+
if (unlikely(oseq < replay_esn->oseq)) {
718+
replay_esn->oseq_hi = ++oseq_hi;
719+
if (xo->seq.low < replay_esn->oseq) {
720+
XFRM_SKB_CB(skb)->seq.output.hi = oseq_hi;
721+
xo->seq.hi = oseq_hi;
722+
}
721723
if (replay_esn->oseq_hi == 0) {
722724
replay_esn->oseq--;
723725
replay_esn->oseq_hi--;

0 commit comments

Comments
 (0)