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

Improve QUIC defragmentation of TLS packets. #158

Closed

Conversation

bwelling
Copy link

This avoids excessive persistent memory usage associated with every QUIC connection, by avoiding a large (21k) preallocation of a buffer used for defragmentation of TLS packets.

Instead of preallocating space for all TLS data, this only stores TLS fragments that cannot be fully assembled on the connection.

This avoids excessive persistent memory usage associated with every QUIC
connection, by avoiding a large (21k) preallocation of a buffer used for
defragmentation of TLS packets.

Instead of preallocating space for all TLS data, this only stores TLS
fragments that cannot be fully assembled on the connection.
@bwelling
Copy link
Author

This addresses the issue in #157.

As far as I can tell, there isn't any real testing of calling SSL_provide_quic_data with differently framed TLS fragments, and I don't know how to write all of these tests from scratch.

@wbl wbl requested review from wbl and tmshort May 1, 2024 18:58
Copy link
Collaborator

@wbl wbl left a comment

Choose a reason for hiding this comment

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

I think we need to figure out what our compiler support for flexible array members looks like first.

size_t length;
/* char data[]; should be here but C90 VLAs not allowed here */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Paragraph 6.7.3.2.20 of n3220 permits flexible arrays as last element which would be allowed. However I think we need to double check what century our compilers are from. This is probably the clean way to do what you want, as I'm not sure if what you're doing is undefined behavior or not in all places

Copy link
Member

Choose a reason for hiding this comment

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

I would also be inclined to use real C99 flexible arrays.
On a different project investigating the question of flexible array support, my colleague wrote "Using the godbolt.org side, I couldn't find a gcc or clang level that didn't support flex arrays.". That project ended up using an autoconf test with some probably-undefined-behavior alternative for systems that don't support flexible arrays (e.g., AIX), whose compilers can probably safely be assumed to not be trying to do anything with that undefined behavior.
quictls inherits its configure script from openssl, and does not have real facility for autoconf-style "try a build and see if it works" checks, but our target audience is also probably for modern enough systems that we could just assume support for it. (That same other project I mentioned also concluded that Microsoft's compilers supported it as an extension well before it was standardized.)

Copy link
Author

Choose a reason for hiding this comment

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

I don't have any strong preference. That part of the change was simply restoring code from 075ede1.

Copy link
Member

Choose a reason for hiding this comment

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

I'm good with flexible arrays. @nibanks ?

@tmshort
Copy link
Member

tmshort commented Aug 12, 2024

When 3.1.6 is ready, this should be rebased... but we can always pull the commit over.

@wbl wbl requested a review from nibanks September 3, 2024 16:16
@wbl
Copy link
Collaborator

wbl commented Sep 3, 2024

I've added nibanks as a reviewer. Let's figure out how to release this on 3.1.7 after we finish making it (bump a version somehow with a suffix?) or agree it's good for 3.1.8/whatever happens next. Still need input from nibanks on if VLA will work for him: suspect answer is yes. (And I think that means a code change if yes)

@nibanks
Copy link
Member

nibanks commented Sep 3, 2024

I don't have a lot of feedback except to add that MsQuic explicitly looks at the TLS framing layer to ensure it never gives a fragment down to the lower layer, so it can completely handle the complexity itself the same across all TLS libraries. So we don't need any large preallocated buffer. But that's just MsQuic...

@wbl
Copy link
Collaborator

wbl commented Sep 3, 2024

What about the use of VLA? I think that would make the patch nicer, as I'm not 100% sure of the current code being right. It would however mean updating our C level to C99, and we want to be sure you're onboard with that.

@wbl
Copy link
Collaborator

wbl commented Sep 16, 2024

We are all good with VLA @bwelling could you adjust your patch and rebase on 3.1.7, and then we can release with it?

@bwelling
Copy link
Author

I opened a new PR for the existing patch against 3.1.7. I'm not sure what VLA changes are wanted or needed, so it would probably be easier for someone who does know to make the changes.

@bwelling
Copy link
Author

Replaced by #173.

@bwelling bwelling closed this Sep 16, 2024
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.

7 participants