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()
103 if (unlikely(x->replay.oseq == 0)) { in xfrm_replay_overflow()
104 x->replay.oseq--; in xfrm_replay_overflow()
105 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow()
111 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow()
117 static int xfrm_replay_check(struct xfrm_state *x, in xfrm_replay_check() argument
123 if (!x->props.replay_window) in xfrm_replay_check()
129 if (likely(seq > x->replay.seq)) in xfrm_replay_check()
132 diff = x->replay.seq - seq; in xfrm_replay_check()
133 if (diff >= x->props.replay_window) { in xfrm_replay_check()
134 x->stats.replay_window++; in xfrm_replay_check()
138 if (x->replay.bitmap & (1U << diff)) { in xfrm_replay_check()
139 x->stats.replay++; in xfrm_replay_check()
145 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check()
149 static void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance() argument
154 if (!x->props.replay_window) in xfrm_replay_advance()
157 if (seq > x->replay.seq) { in xfrm_replay_advance()
158 diff = seq - x->replay.seq; in xfrm_replay_advance()
159 if (diff < x->props.replay_window) in xfrm_replay_advance()
160 x->replay.bitmap = ((x->replay.bitmap) << diff) | 1; in xfrm_replay_advance()
162 x->replay.bitmap = 1; in xfrm_replay_advance()
163 x->replay.seq = seq; in xfrm_replay_advance()
165 diff = x->replay.seq - seq; in xfrm_replay_advance()
166 x->replay.bitmap |= (1U << diff); in xfrm_replay_advance()
169 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance()
170 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance()
173 static int xfrm_replay_overflow_bmp(struct xfrm_state *x, struct sk_buff *skb) in xfrm_replay_overflow_bmp() argument
176 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_overflow_bmp()
177 struct net *net = xs_net(x); in xfrm_replay_overflow_bmp()
179 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { in xfrm_replay_overflow_bmp()
184 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow_bmp()
190 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow_bmp()
196 static int xfrm_replay_check_bmp(struct xfrm_state *x, in xfrm_replay_check_bmp() argument
200 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_check_bmp()
215 x->stats.replay_window++; in xfrm_replay_check_bmp()
234 x->stats.replay++; in xfrm_replay_check_bmp()
236 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check_bmp()
240 static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance_bmp() argument
244 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_advance_bmp()
284 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance_bmp()
285 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance_bmp()
288 static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event) in xfrm_replay_notify_bmp() argument
291 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_notify_bmp()
292 struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; in xfrm_replay_notify_bmp()
306 if (!x->replay_maxdiff || in xfrm_replay_notify_bmp()
307 ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) && in xfrm_replay_notify_bmp()
309 < x->replay_maxdiff))) { in xfrm_replay_notify_bmp()
310 if (x->xflags & XFRM_TIME_DEFER) in xfrm_replay_notify_bmp()
319 if (memcmp(x->replay_esn, x->preplay_esn, in xfrm_replay_notify_bmp()
321 x->xflags |= XFRM_TIME_DEFER; in xfrm_replay_notify_bmp()
328 memcpy(x->preplay_esn, x->replay_esn, in xfrm_replay_notify_bmp()
332 km_state_notify(x, &c); in xfrm_replay_notify_bmp()
334 if (x->replay_maxage && in xfrm_replay_notify_bmp()
335 !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) in xfrm_replay_notify_bmp()
336 x->xflags &= ~XFRM_TIME_DEFER; in xfrm_replay_notify_bmp()
339 static void xfrm_replay_notify_esn(struct xfrm_state *x, int event) in xfrm_replay_notify_esn() argument
343 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_notify_esn()
344 struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; in xfrm_replay_notify_esn()
358 if (x->replay_maxdiff) { in xfrm_replay_notify_esn()
372 if (seq_diff >= x->replay_maxdiff || in xfrm_replay_notify_esn()
373 oseq_diff >= x->replay_maxdiff) in xfrm_replay_notify_esn()
377 if (x->xflags & XFRM_TIME_DEFER) in xfrm_replay_notify_esn()
385 if (memcmp(x->replay_esn, x->preplay_esn, in xfrm_replay_notify_esn()
387 x->xflags |= XFRM_TIME_DEFER; in xfrm_replay_notify_esn()
394 memcpy(x->preplay_esn, x->replay_esn, in xfrm_replay_notify_esn()
398 km_state_notify(x, &c); in xfrm_replay_notify_esn()
400 if (x->replay_maxage && in xfrm_replay_notify_esn()
401 !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) in xfrm_replay_notify_esn()
402 x->xflags &= ~XFRM_TIME_DEFER; in xfrm_replay_notify_esn()
405 static int xfrm_replay_overflow_esn(struct xfrm_state *x, struct sk_buff *skb) in xfrm_replay_overflow_esn() argument
408 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_overflow_esn()
409 struct net *net = xs_net(x); in xfrm_replay_overflow_esn()
411 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { in xfrm_replay_overflow_esn()
421 xfrm_audit_state_replay_overflow(x, skb); in xfrm_replay_overflow_esn()
428 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_overflow_esn()
434 static int xfrm_replay_check_esn(struct xfrm_state *x, in xfrm_replay_check_esn() argument
439 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_check_esn()
468 x->stats.replay_window++; in xfrm_replay_check_esn()
487 x->stats.replay++; in xfrm_replay_check_esn()
489 xfrm_audit_state_replay(x, skb, net_seq); in xfrm_replay_check_esn()
493 static int xfrm_replay_recheck_esn(struct xfrm_state *x, in xfrm_replay_recheck_esn() argument
497 htonl(xfrm_replay_seqhi(x, net_seq)))) { in xfrm_replay_recheck_esn()
498 x->stats.replay_window++; in xfrm_replay_recheck_esn()
502 return xfrm_replay_check_esn(x, skb, net_seq); in xfrm_replay_recheck_esn()
505 static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq) in xfrm_replay_advance_esn() argument
510 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_replay_advance_esn()
517 seq_hi = xfrm_replay_seqhi(x, net_seq); in xfrm_replay_advance_esn()
557 if (xfrm_aevent_is_on(xs_net(x))) in xfrm_replay_advance_esn()
558 x->repl->notify(x, XFRM_REPLAY_UPDATE); in xfrm_replay_advance_esn()
585 int xfrm_init_replay(struct xfrm_state *x) in xfrm_init_replay() argument
587 struct xfrm_replay_state_esn *replay_esn = x->replay_esn; in xfrm_init_replay()
594 if (x->props.flags & XFRM_STATE_ESN) { in xfrm_init_replay()
597 x->repl = &xfrm_replay_esn; in xfrm_init_replay()
599 x->repl = &xfrm_replay_bmp; in xfrm_init_replay()
601 x->repl = &xfrm_replay_legacy; in xfrm_init_replay()