ktls / af_ktls

Linux Kernel TLS/DTLS Module
GNU General Public License v2.0
159 stars 25 forks source link

support poll #33

Closed djwatson closed 8 years ago

djwatson commented 8 years ago

Poll isn't currently supported. Related, it looks like recvmsg / sendmsg don't block in blocking mode.

lancerchao commented 8 years ago

A simple implementation would be to piggy-back off tsk->socket's poll e.g.


static unsigned int tls_poll(struct file *file, struct socket *sock,
              struct poll_table_struct *wait) {
    struct tls_sock *tsk;
    tsk = tls_sk(sock->sk);
    return tsk->socket->ops->poll(tsk->socket->file, tsk->socket, wait);
fridex commented 8 years ago

I was thinking about the same approach. We have to keep in mind, that we are above TCP/UDP. E.g. for POLLERR we should consider even errors during decryption (etc).

For now it will be probably OK to return ENOTSUPP for unsupported cases IMHO.

Just a note regarding POLLPRI in TCP - there should be implemented OOB support in tcp_read_sock() once we switch to it (see #21).

djwatson commented 8 years ago

For writes, this approach should work fine. For reads, tcp does the wakeup via the original sk_data_ready, so we would need to make sure we call it in the right places

fridex commented 8 years ago

A custom callback tls_data_ready just spawns a worker and calls the original sk_data_ready to wake up possibly waiting recipient. The issue here I see is the asynchronous decryption that can make poll(2) tricky to implement for some events.

djwatson commented 8 years ago

fixed by https://github.com/ktls/af_ktls/pull/62