Lines Matching refs:x
24 u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_seqhi() argument
27 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_seqhi()
29 if (!(x->props.flags & XFRM_STATE_ESN)) in xfrm_replay_seqhi()
49 static void xfrm_replay_notify(struct xfrm_state *x, int event) in xfrm_replay_notify() argument
64 if (!x->replay_maxdiff || in xfrm_replay_notify()
65 ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) && in xfrm_replay_notify()
66 (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) { in xfrm_replay_notify()
67 if (x->xflags & XFRM_TIME_DEFER) in xfrm_replay_notify()
76 if (memcmp(&x->replay, &x->preplay, in xfrm_replay_notify()
78 x->xflags |= XFRM_TIME_DEFER; in xfrm_replay_notify()
85 memcpy(&x->preplay, &x->replay, sizeof(struct xfrm_replay_state)); in xfrm_replay_notify()
88 km_state_notify(x, &c); in xfrm_replay_notify()
90 if (x->replay_maxage && in xfrm_replay_notify()
91 !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) in xfrm_replay_notify()
92 x->xflags &= ~XFRM_TIME_DEFER; in xfrm_replay_notify()
95 static int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb) in xfrm_replay_overflow() argument
98 struct net *net = xs_net(x); in xfrm_replay_overflow()
100 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { in xfrm_replay_overflow()
101 XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq; in xfrm_replay_overflow()
102 if (unlikely(x->replay.oseq == 0)) { in xfrm_replay_overflow()
103 x->replay.oseq--; in xfrm_replay_overflow()
104 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow()
110 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow()
116 static int xfrm_replay_check(struct xfrm_state *x, in xfrm_replay_check() argument
122 if (!x->props.replay_window) in xfrm_replay_check()
128 if (likely(seq > x->replay.seq)) in xfrm_replay_check()
131 diff = x->replay.seq - seq; in xfrm_replay_check()
132 if (diff >= x->props.replay_window) { in xfrm_replay_check()
133 x->stats.replay_window++; in xfrm_replay_check()
137 if (x->replay.bitmap & (1U << diff)) { in xfrm_replay_check()
138 x->stats.replay++; in xfrm_replay_check()
144 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check()
148 static void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance() argument
153 if (!x->props.replay_window) in xfrm_replay_advance()
156 if (seq > x->replay.seq) { in xfrm_replay_advance()
157 diff = seq - x->replay.seq; in xfrm_replay_advance()
158 if (diff < x->props.replay_window) in xfrm_replay_advance()
159 x->replay.bitmap = ((x->replay.bitmap) << diff) | 1; in xfrm_replay_advance()
161 x->replay.bitmap = 1; in xfrm_replay_advance()
162 x->replay.seq = seq; in xfrm_replay_advance()
164 diff = x->replay.seq - seq; in xfrm_replay_advance()
165 x->replay.bitmap |= (1U << diff); in xfrm_replay_advance()
168 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance()
169 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance()
172 static int xfrm_replay_overflow_bmp(struct xfrm_state *x, struct sk_buff *skb) in xfrm_replay_overflow_bmp() argument
175 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_overflow_bmp()
176 struct net *net = xs_net(x); in xfrm_replay_overflow_bmp()
178 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { in xfrm_replay_overflow_bmp()
182 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow_bmp()
188 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow_bmp()
194 static int xfrm_replay_check_bmp(struct xfrm_state *x, in xfrm_replay_check_bmp() argument
198 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_check_bmp()
213 x->stats.replay_window++; in xfrm_replay_check_bmp()
232 x->stats.replay++; in xfrm_replay_check_bmp()
234 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check_bmp()
238 static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance_bmp() argument
242 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_advance_bmp()
282 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance_bmp()
283 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance_bmp()
286 static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event) in xfrm_replay_notify_bmp() argument
289 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_notify_bmp()
290 struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; in xfrm_replay_notify_bmp()
304 if (!x->replay_maxdiff || in xfrm_replay_notify_bmp()
305 ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) && in xfrm_replay_notify_bmp()
307 < x->replay_maxdiff))) { in xfrm_replay_notify_bmp()
308 if (x->xflags & XFRM_TIME_DEFER) in xfrm_replay_notify_bmp()
317 if (memcmp(x->replay_esn, x->preplay_esn, in xfrm_replay_notify_bmp()
319 x->xflags |= XFRM_TIME_DEFER; in xfrm_replay_notify_bmp()
326 memcpy(x->preplay_esn, x->replay_esn, in xfrm_replay_notify_bmp()
330 km_state_notify(x, &c); in xfrm_replay_notify_bmp()
332 if (x->replay_maxage && in xfrm_replay_notify_bmp()
333 !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) in xfrm_replay_notify_bmp()
334 x->xflags &= ~XFRM_TIME_DEFER; in xfrm_replay_notify_bmp()
337 static void xfrm_replay_notify_esn(struct xfrm_state *x, int event) in xfrm_replay_notify_esn() argument
341 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_notify_esn()
342 struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; in xfrm_replay_notify_esn()
356 if (x->replay_maxdiff) { in xfrm_replay_notify_esn()
370 if (seq_diff >= x->replay_maxdiff || in xfrm_replay_notify_esn()
371 oseq_diff >= x->replay_maxdiff) in xfrm_replay_notify_esn()
375 if (x->xflags & XFRM_TIME_DEFER) in xfrm_replay_notify_esn()
383 if (memcmp(x->replay_esn, x->preplay_esn, in xfrm_replay_notify_esn()
385 x->xflags |= XFRM_TIME_DEFER; in xfrm_replay_notify_esn()
392 memcpy(x->preplay_esn, x->replay_esn, in xfrm_replay_notify_esn()
396 km_state_notify(x, &c); in xfrm_replay_notify_esn()
398 if (x->replay_maxage && in xfrm_replay_notify_esn()
399 !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) in xfrm_replay_notify_esn()
400 x->xflags &= ~XFRM_TIME_DEFER; in xfrm_replay_notify_esn()
403 static int xfrm_replay_overflow_esn(struct xfrm_state *x, struct sk_buff *skb) in xfrm_replay_overflow_esn() argument
406 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_overflow_esn()
407 struct net *net = xs_net(x); in xfrm_replay_overflow_esn()
409 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { in xfrm_replay_overflow_esn()
419 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow_esn()
426 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow_esn()
432 static int xfrm_replay_check_esn(struct xfrm_state *x, in xfrm_replay_check_esn() argument
437 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_check_esn()
466 x->stats.replay_window++; in xfrm_replay_check_esn()
485 x->stats.replay++; in xfrm_replay_check_esn()
487 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check_esn()
491 static int xfrm_replay_recheck_esn(struct xfrm_state *x, in xfrm_replay_recheck_esn() argument
495 htonl(xfrm_replay_seqhi(x, net_seq)))) { in xfrm_replay_recheck_esn()
496 x->stats.replay_window++; in xfrm_replay_recheck_esn()
500 return xfrm_replay_check_esn(x, skb, net_seq); in xfrm_replay_recheck_esn()
503 static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance_esn() argument
508 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_advance_esn()
515 seq_hi = xfrm_replay_seqhi(x, net_seq); in xfrm_replay_advance_esn()
555 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance_esn()
556 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance_esn()
583 int xfrm_init_replay(struct xfrm_state *x) in xfrm_init_replay() argument
585 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_init_replay()
592 if (x->props.flags & XFRM_STATE_ESN) { in xfrm_init_replay()
595 x->repl = &xfrm_replay_esn; in xfrm_init_replay()
597 x->repl = &xfrm_replay_bmp; in xfrm_init_replay()
599 x->repl = &xfrm_replay_legacy; in xfrm_init_replay()