crypto_dispatch_async() marks an ordered request with
CRYPTO_F_ASYNC_ORDERED and gives it a sequence number. The return
thread runs the callbacks in sequence and only takes the head of its
ordered queue when the head carries the next number.
When a driver unregisters, the request completes with EAGAIN and the
ESP and AH callbacks dispatch it again with crypto_dispatch(). The
flag is still set, so crypto_done() puts the request back on the
ordered queue under the number the return thread has already passed.
The head of the queue never matches again, and no ordered request of
any session on that return worker completes after that.
Before crypto_dispatch_async() existed, crypto_dispatch() gave such a
request a new sequence number. Clear the flag when the return thread
takes a request off the ordered queue, so a request that is dispatched
again completes like any other.
Fixes: 68f6800ce05c ("opencrypto: Introduce crypto_dispatch_async()")
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")