|
|
@@ -545,10 +545,22 @@ static int tls_device_push_pending_record(struct sock *sk, int flags)
|
|
|
return tls_push_data(sk, &msg_iter, 0, flags, TLS_RECORD_TYPE_DATA);
|
|
|
}
|
|
|
|
|
|
+static void tls_device_resync_rx(struct tls_context *tls_ctx,
|
|
|
+ struct sock *sk, u32 seq, u64 rcd_sn)
|
|
|
+{
|
|
|
+ struct net_device *netdev;
|
|
|
+
|
|
|
+ if (WARN_ON(test_and_set_bit(TLS_RX_SYNC_RUNNING, &tls_ctx->flags)))
|
|
|
+ return;
|
|
|
+ netdev = READ_ONCE(tls_ctx->netdev);
|
|
|
+ if (netdev)
|
|
|
+ netdev->tlsdev_ops->tls_dev_resync_rx(netdev, sk, seq, rcd_sn);
|
|
|
+ clear_bit_unlock(TLS_RX_SYNC_RUNNING, &tls_ctx->flags);
|
|
|
+}
|
|
|
+
|
|
|
void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn)
|
|
|
{
|
|
|
struct tls_context *tls_ctx = tls_get_ctx(sk);
|
|
|
- struct net_device *netdev = tls_ctx->netdev;
|
|
|
struct tls_offload_context_rx *rx_ctx;
|
|
|
u32 is_req_pending;
|
|
|
s64 resync_req;
|
|
|
@@ -563,10 +575,10 @@ void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn)
|
|
|
is_req_pending = resync_req;
|
|
|
|
|
|
if (unlikely(is_req_pending) && req_seq == seq &&
|
|
|
- atomic64_try_cmpxchg(&rx_ctx->resync_req, &resync_req, 0))
|
|
|
- netdev->tlsdev_ops->tls_dev_resync_rx(netdev, sk,
|
|
|
- seq + TLS_HEADER_SIZE - 1,
|
|
|
- rcd_sn);
|
|
|
+ atomic64_try_cmpxchg(&rx_ctx->resync_req, &resync_req, 0)) {
|
|
|
+ seq += TLS_HEADER_SIZE - 1;
|
|
|
+ tls_device_resync_rx(tls_ctx, sk, seq, rcd_sn);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static int tls_device_reencrypt(struct sock *sk, struct sk_buff *skb)
|
|
|
@@ -954,7 +966,10 @@ static int tls_device_down(struct net_device *netdev)
|
|
|
if (ctx->rx_conf == TLS_HW)
|
|
|
netdev->tlsdev_ops->tls_dev_del(netdev, ctx,
|
|
|
TLS_OFFLOAD_CTX_DIR_RX);
|
|
|
- ctx->netdev = NULL;
|
|
|
+ WRITE_ONCE(ctx->netdev, NULL);
|
|
|
+ smp_mb__before_atomic(); /* pairs with test_and_set_bit() */
|
|
|
+ while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags))
|
|
|
+ usleep_range(10, 200);
|
|
|
dev_put(netdev);
|
|
|
list_del_init(&ctx->list);
|
|
|
|