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

Ktls buffer revamp #62

Merged
merged 17 commits into from
Jul 28, 2016
Merged

Ktls buffer revamp #62

merged 17 commits into from
Jul 28, 2016

Conversation

lancerchao
Copy link
Contributor

Pull request that includes all my diffs for the past 2 weeks.

fridex and others added 10 commits July 8, 2016 17:22
This fixed the way that recvmsg is handled. Asynchronous worker
now decrypts directly on skbuffs rather than using kernel_recvmsg.
Records that come into TCP rcvq are cloned and assembled into a
single skb. This skb is then converted to a sgvec and passed to
decryption routine. Decryption routine decrypts inplace, and the skb
is added to TLS rcvq.

Recvmsg checks TLS rcvq and copies them to user buffer.

There should only be a single copy during decryption- from skbuff
to user space.

Splice is not yet supported.
Tested with af_ktls-tests. Basic functionalities work.
from the underlying socket in the event that a non-encrypted message
is received.
Some of the logic for reading the TLS record had to be changed.
It is not safe to automatically read KTLS_TLS_PREPEND_SIZE bytes
since control messages shorter than that would be missed.
…or. An error is raised when decryption fails in TLS_TCP_RECV
@fridex fridex mentioned this pull request Jul 9, 2016
tsk->iv_recv);

/*
* Decrypt in place.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a serious bottleneck for AES GCM. We shouldn't decrypt in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative would be to allocate another skb for decrypted data. According to Dave, decrypting in place does not incur any extra overhead. The hope is that once we fix high memory issues, we can use skb_clone() instead of skb_copy(), therefore requiring less space for decryption.

@djwatson
Copy link
Member

djwatson commented Jul 12, 2016

First commit looks like a bad merge and can be dropped

/*
*Copy header to use later in decryption.
*An optimization could be to zero-copy, but you'd
*have to be able to deal with frag_list bs. This function call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 'bs'

So it turns out there is no issue of high memory. The scatterwalk API
_does_ kmap pages as necessary. The actual bug was me being stupid and
not initializing the sgtable every time, causing some of the pages
to be marked as "sg_last_page" when they actually are not and
causing null pointer exceptions
@fridex
Copy link
Member

fridex commented Jul 20, 2016

OK, so could we merge this with the first patch dropped and with removed changes in gitignore file (4c454ba and b15a7b8)? And also with this change: #62 (comment)

@lancerchao
Copy link
Contributor Author

Yes, I think it is ready. This code is passing FB tests as well.

@djwatson djwatson merged commit 0c7d058 into ktls:master Jul 28, 2016
@lancerchao lancerchao deleted the ktls_buffer_revamp branch August 10, 2016 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants