@@ -1749,6 +1749,7 @@ void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq);
int xfrm_replay_check(struct xfrm_state *x, struct sk_buff *skb, __be32 net_seq);
void xfrm_replay_notify(struct xfrm_state *x, int event);
int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb);
+bool xfrm_replay_overflow_check(struct xfrm_state *x, struct sk_buff *skb);
int xfrm_replay_recheck(struct xfrm_state *x, struct sk_buff *skb, __be32 net_seq);
static inline int xfrm_aevent_is_on(struct net *net)
@@ -738,7 +738,7 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
skb->encapsulation = 1;
if (skb_is_gso(skb)) {
- if (skb->inner_protocol)
+ if (skb->inner_protocol || xfrm_replay_overflow_check(x, skb))
return xfrm_output_gso(net, sk, skb);
skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
@@ -750,6 +750,27 @@ int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)
return xfrm_replay_overflow_offload(x, skb);
}
+
+bool xfrm_replay_overflow_check(struct xfrm_state *x, struct sk_buff *skb)
+{
+ struct xfrm_replay_state_esn *replay_esn = x->replay_esn;
+ __u32 oseq = replay_esn->oseq;
+
+ /* We assume that this function is called with
+ * skb_is_gso(skb) == true
+ */
+
+ if (x->repl_mode == XFRM_REPLAY_MODE_ESN) {
+ if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
+ oseq = oseq + 1 + skb_shinfo(skb)->gso_segs;
+ if (unlikely(oseq < replay_esn->oseq))
+ return true;
+ }
+ }
+
+ return false;
+}
+
#else
int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)
{
@@ -764,6 +785,11 @@ int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)
return __xfrm_replay_overflow(x, skb);
}
+
+bool xfrm_replay_overflow_check(struct xfrm_state *x, struct sk_buff *skb)
+{
+ return false;
+}
#endif
int xfrm_init_replay(struct xfrm_state *x)