Skip to content

Commit

Permalink
Only create a new QuicChannel when receiving an INITIAL packet (java-…
Browse files Browse the repository at this point in the history
…native-access#720)

Motivation:

We should only try to create a new QuicChannel when receiving an INITIAL
packets. For all the other packets we want to just drop the packet on
the floor if there is no existing mapping.

Modifications:

Only create a new QuicChannel on receiving an INITAL packet

Result:

Correctly handle creation of new QuicChannel
  • Loading branch information
normanmaurer authored Jun 7, 2024
1 parent a34c99d commit 4fc6297
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,30 @@ protected QuicheQuicChannel quicPacketRead(ChannelHandlerContext ctx, InetSocket
throws Exception {
ByteBuffer dcidByteBuffer = dcid.internalNioBuffer(dcid.readerIndex(), dcid.readableBytes());
QuicheQuicChannel channel = getChannel(dcidByteBuffer);
if (channel == null && type == QuicPacketType.ZERO_RTT && connectionIdAddressGenerator.isIdempotent()) {
// 0 rtt packet should obtain the server generated dcid
channel = getChannel(connectionIdAddressGenerator.newId(dcidByteBuffer, localConnIdLength));
if (channel != null) {
return channel;
}
if (channel == null) {
return handleServer(ctx, sender, recipient, type, version, scid, dcid, token,
senderSockaddrMemory, recipientSockaddrMemory, freeTask, localConnIdLength, config);
switch (type) {
case ZERO_RTT:
if (connectionIdAddressGenerator.isIdempotent()) {
// Try to see if we can find the channel by generate the previous used DCID again.
channel = getChannel(connectionIdAddressGenerator.newId(dcidByteBuffer, localConnIdLength));
if (channel == null) {
return null;
}
} else {
return null;
}
case INITIAL:
// We only want to possibility create a new QuicChannel if this is the initial packet, otherwise
// drop the packet on the floor if we did not find a mapping before.
return handleServer(ctx, sender, recipient, type, version, scid, dcid, token,
senderSockaddrMemory, recipientSockaddrMemory, freeTask, localConnIdLength, config);
default:
// Drop the packet on the floor.
return null;
}

return channel;
}

@Nullable
Expand Down

0 comments on commit 4fc6297

Please sign in to comment.