Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do MSG_PEEK call only once #37

Closed
fridex opened this issue May 18, 2016 · 1 comment
Closed

Do MSG_PEEK call only once #37

fridex opened this issue May 18, 2016 · 1 comment

Comments

@fridex
Copy link
Member

fridex commented May 18, 2016

Based on https://github.com/fridex/af_ktls/pull/28 I am open to discussion whether there can be only one peek or two peeks per kernel_recvmsg() and splice_read.

We should distinguish stream (TCP) and datagram (UDP) protocols here. As was discussed in https://github.com/fridex/af_ktls/pull/28. This should be a full list of scenarios that can happen:

  • for DTLS/UDP:
    • EBADF when peeked size is bigger then we expect based on header
    • EBADF when peeked size is smaller then we expect based on header (or does not cover header at all)
    • when equal, process
  • for TLS/TCP:
    • when peeked size is bigger than size based on TLS header, process only TLS record - part based on TLS header
    • when peeked size is smaller than size based on TLS header or it does not cover header at all (possibly segmented):
      • EAGAIN for nonblocking socket
      • block for blocking socket
    • when equal, proces

Can we peek only once (not a separate peek for header and then for the record)?

  • for DTLS/UDP it should be pretty straight forward, since when we do the peek, the whole datagram should be already available
  • for TLS/TCP:
    • since we explicitly know where is the beginning and the end of the TLS record, we could wait/report when there is not enough data
    • for nonblocking socket scenario, there can be incosistency in return value:
      1. not enough data received to handle whole record - kernel will return EAGAIN
      2. received whole record, but it was not possible to decrypt it - kernel will return EBADF (probably)
        Note this will occur even with double-peek approach

Nevertheless, peek is not a big deal though (as discussed in #28).

Any suggestions?

related: https://github.com/fridex/af_ktls/pull/28 https://github.com/fridex/af_ktls/issues/21

@djwatson
Copy link
Member

fixed by using skb methods, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants