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

Support customized Cid generation #851

Merged
merged 19 commits into from
Oct 3, 2020
Merged

Conversation

liwenjieQu
Copy link
Contributor

Currently Quinn generates cid using random number only. Some use case may require a more sophisticated cid structure. This change mainly add a ConnectionIdGenerator trait that allows to use any customized cid generator.

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I agree that we should expose something like this, e.g. to support load balancers. Out of curiosity, are you doing something with Quinn that requires this in practice?

@liwenjieQu liwenjieQu requested a review from Ralith September 18, 2020 19:06
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Made a deep pass; mostly cosmetic issues.

liwenjieQu and others added 4 commits September 21, 2020 09:18
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
@liwenjieQu liwenjieQu requested a review from Ralith September 21, 2020 18:56
liwenjieQu and others added 4 commits September 22, 2020 13:39
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
@liwenjieQu liwenjieQu requested a review from Ralith September 22, 2020 22:07
Ralith
Ralith previously approved these changes Sep 28, 2020
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Thanks for your work!

@liwenjieQu
Copy link
Contributor Author

Appreciate your time @Ralith !

@liwenjieQu
Copy link
Contributor Author

Could you squash and merge these commits so I can push a new PR? Thanks

@Ralith
Copy link
Collaborator

Ralith commented Sep 28, 2020

I'd prefer to get a signoff from @djc first. You can make a new PR based on this branch, and when we merge this to master you should be able to rebase the new PR onto master without issue, and I'll happily review the new parts in the mean time. You could also squash this branch into a single commit yourself first for extra insurance against git getting tangled up.

@liwenjieQu
Copy link
Contributor Author

Just realize that I need to remove 'crate' from pub(crate) before new function for ConnectionId, and thus a third-party cid generator trait can implement generate_cid on its own

@liwenjieQu liwenjieQu requested a review from Ralith September 29, 2020 05:29
@Ralith
Copy link
Collaborator

Ralith commented Sep 29, 2020

Whoops, good catch.

Ralith
Ralith previously approved these changes Sep 29, 2020
@liwenjieQu
Copy link
Contributor Author

The error from CI is mysterious. I am using a Mac and all tests pass on my side.

@Ralith
Copy link
Collaborator

Ralith commented Sep 29, 2020

There's a similar issue on #850; I'm guessing it's on github's end and we should ignore it.

@liwenjieQu
Copy link
Contributor Author

Please not merge the PR now. I need to update the CID generator trait for proactive cid rotation liwenjieQu#1 where the lifetime/duration of a CID needs to be returned. I think it is better to declare in the very beginning to avoid breaking compatibility

@liwenjieQu
Copy link
Contributor Author

Sorry for the inconvenience that the PR has to be reviewed again.

@liwenjieQu liwenjieQu requested a review from Ralith September 29, 2020 22:43
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Good catch. Minor API breakage isn't the end of the world at present, but might as well avoid it when we can.

Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
@djc djc merged commit 37a2fde into quinn-rs:master Oct 3, 2020
@djc
Copy link
Member

djc commented Oct 3, 2020

Sorry for the delayed review -- thanks for working on this, it looks pretty good!

djc added a commit that referenced this pull request Oct 3, 2020
Ralith pushed a commit that referenced this pull request Oct 3, 2020
@liwenjieQu liwenjieQu mentioned this pull request Oct 4, 2020
@@ -341,7 +345,7 @@ where
if self.is_full() {
return Err(ConnectError::TooManyConnections);
}
let remote_id = ConnectionId::random(&mut self.rng, MAX_CID_SIZE);
let (remote_id, _) = RandomConnectionIdGenerator::new(MAX_CID_SIZE).generate_cid();
Copy link
Contributor

Choose a reason for hiding this comment

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

@liwenjieQu Is there any reason we hardcode the generator here, and don't use the local_cid_generator? The main difference I see between RandomConnectionIdGenerator vs local_cid_generator is the cid_len.

Here we pass remote_id to add_connection. However inside that function, we pass self._local_cid_generator to Connection::new which uses its length, instead of the length of remote_id (which was generated by RandomConnectionIdGenerator).

Should we change this to be self.local_cid_generator.generate_cid() for consistency.?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note the name remote_id; we're generating a destination connection ID here, not a local one. The client uses a random destination connection ID for its initial flight of packets; see https://quicwg.org/base-drafts/draft-ietf-quic-transport.html#name-negotiating-connection-ids for details.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ralith Thanks for the explanation! That clears it up.

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.

5 participants