-
Notifications
You must be signed in to change notification settings - Fork 30k
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
http2: add aligned padding strategy #17938
Conversation
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes.
Ping @addaleax ... for some reason I'm not able to open a new issue in the repo... but I can comment on issues and I can add PRs... very strange... In any case, I came across an issue you may want to look at: @addaleax ... heads up... when using the That is, modifying 'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');
const makeDuplexPair = require('../common/duplexpair');
{
const testData = '<h1>Hello World</h1>';
const server = http2.createServer();
server.on('stream', common.mustCall((stream, headers) => {
stream.respond({
'content-type': 'text/html',
':status': 200
});
stream.end(testData);
}));
const { clientSide, serverSide } = makeDuplexPair();
server.emit('connection', serverSide);
serverSide.on('data', () => {
throw 'something';
});
const client = http2.connect('http://localhost:80', {
createConnection: common.mustCall(() => clientSide)
});
const req = client.request({ ':path': '/' });
req.on('response', common.mustCall((headers) => {
assert.strictEqual(headers[':status'], 200);
}));
req.setEncoding('utf8');
// Note: This is checking that this small amount of data is passed through in
// a single chunk, which is unusual for our test suite but seems like a
// reasonable assumption here.
req.on('data', common.mustCall((data) => {
assert.strictEqual(data, testData);
}));
req.on('end', common.mustCall(() => {
clientSide.destroy();
clientSide.end();
}));
req.end();
} results in:
|
@jasnell I can’t open issues either. :/ Thanks for the pointer though! |
* `http2.constants.PADDING_STRATEGY_ALIGNED` - Will *attempt* to apply | ||
enough padding to ensure that the total frame length, including the | ||
9-byte header, is a multiple of 8. For each frame, however, there is a | ||
maxmimum allowed number of padding bytes that is determined by current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit: maxmimum -> maximum.
when it is better to use one strategy or another? In other terms, should this be the default? |
That's still unclear and needs to be benchmarked to determine the best strategy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@jasnell after this is landed, can you open up a new issue for picking the best strategy? |
Yep, definitely. The "best" is going to depend on a number of factors and may be difficult to nail down. Padding is supposed to be a security mechanism (see https://tools.ietf.org/html/rfc7540#section-10.7) but it's use really depends on a number of very data-specific and use-case-specific factors. For instance, one reason why the aligned strategy might not make the best default is this particular passage in the RFC:
In other words, aligned padding might may buffer allocation easier, but it also makes frame sizes more predictable. |
CI is good |
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. PR-URL: #17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Landed in efdadcc |
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Ref: nodejs#17938 (comment)
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. PR-URL: nodejs#17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. Backport-PR-URL: #18050 PR-URL: #17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. Backport-PR-URL: #18050 PR-URL: #17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. Backport-PR-URL: nodejs#18050 PR-URL: nodejs#17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Add a padding strategy option that makes a best attempt to ensure that total frame length for DATA and HEADERS frames are aligned on multiples of 8-bytes. Backport-PR-URL: #18050 Backport-PR-URL: #20456 PR-URL: #17938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Add a padding strategy option that makes a best attempt to ensure
that total frame length for DATA and HEADERS frames are aligned
on multiples of 8-bytes.
Ping @nodejs/http2
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
http2