Skip to content

Commit 1283cf7

Browse files
committed
Align max path ID TP and path block CID
1 parent 7d9ccc4 commit 1283cf7

File tree

10 files changed

+66
-21
lines changed

10 files changed

+66
-21
lines changed

loglib/qlog.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,11 @@ void qlog_paths_blocked_frame(FILE* f, bytestream* s)
833833
void qlog_path_cid_blocked_frame(FILE* f, bytestream* s)
834834
{
835835
uint64_t path_id = 0;
836+
uint64_t next_sequence_number = 0;
836837
byteread_vint(s, &path_id);
838+
byteread_vint(s, &next_sequence_number);
837839
fprintf(f, ", \"path_id\": %"PRIu64, path_id);
840+
fprintf(f, ", \"next_sequence_number\": %"PRIu64, next_sequence_number);
838841
}
839842

840843
void qlog_reset_stream_frame(FILE* f, bytestream* s)

picoquic/frames.c

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5871,18 +5871,37 @@ int picoquic_process_ack_of_paths_blocked_frame(picoquic_cnx_t* cnx, const uint8
58715871

58725872
/* PATH CID BLOCKED frame */
58735873
uint8_t* picoquic_format_path_cid_blocked_frame(
5874-
uint8_t* bytes, const uint8_t* bytes_max, uint64_t path_id, int* more_data)
5874+
uint8_t* bytes, const uint8_t* bytes_max, uint64_t path_id, uint64_t next_sequence_number, int* more_data)
58755875
{
58765876
/* This code assumes that the frame type is already skipped */
58775877
uint8_t* bytes0 = bytes;
58785878
if ((bytes = picoquic_frames_varint_encode(bytes, bytes_max, picoquic_frame_type_path_cid_blocked)) == NULL ||
5879-
(bytes = picoquic_frames_varint_encode(bytes, bytes_max, path_id)) == NULL) {
5879+
(bytes = picoquic_frames_varint_encode(bytes, bytes_max, path_id)) == NULL ||
5880+
(bytes = picoquic_frames_varint_encode(bytes, bytes_max, next_sequence_number)) == NULL) {
58805881
bytes = bytes0;
58815882
*more_data = 1;
58825883
}
58835884
return bytes;
58845885
}
58855886

5887+
uint64_t picoquic_path_cid_next_sequence_number(picoquic_path_t * path_x)
5888+
{
5889+
picoquic_remote_cnxid_stash_t* stash = picoquic_find_or_create_remote_cnxid_stash(path_x->cnx, path_x->unique_path_id, 0);
5890+
uint64_t next_sequence_number = 0;
5891+
5892+
if (stash != NULL) {
5893+
picoquic_remote_cnxid_t* remote_cnxid = stash->cnxid_stash_first;
5894+
5895+
while (remote_cnxid != NULL) {
5896+
if (remote_cnxid->sequence >= next_sequence_number) {
5897+
next_sequence_number = remote_cnxid->sequence + 1;
5898+
}
5899+
remote_cnxid = remote_cnxid->next;
5900+
}
5901+
}
5902+
return next_sequence_number;
5903+
}
5904+
58865905
int picoquic_queue_path_cid_blocked_frame(
58875906
picoquic_path_t * path_x)
58885907
{
@@ -5891,8 +5910,10 @@ int picoquic_queue_path_cid_blocked_frame(
58915910
uint8_t frame_buffer[256];
58925911
int is_pure_ack = 0;
58935912
int more_data = 0;
5913+
uint64_t next_sequence_number = picoquic_path_cid_next_sequence_number(path_x);
58945914
uint8_t* bytes_next = picoquic_format_path_cid_blocked_frame(
5895-
frame_buffer, frame_buffer + sizeof(frame_buffer), path_x->unique_path_id, &more_data);
5915+
frame_buffer, frame_buffer + sizeof(frame_buffer), path_x->unique_path_id,
5916+
next_sequence_number, &more_data);
58965917
size_t consumed = bytes_next - frame_buffer;
58975918
ret = picoquic_queue_misc_frame(path_x->cnx, frame_buffer, consumed, is_pure_ack,
58985919
picoquic_packet_context_application);
@@ -5905,21 +5926,26 @@ int picoquic_queue_path_cid_blocked_frame(
59055926
const uint8_t* picoquic_skip_path_cid_blocked_frame(const uint8_t* bytes, const uint8_t* bytes_max)
59065927
{
59075928
/* This code assumes that the frame type is already skipped */
5908-
bytes = picoquic_frames_varint_skip(bytes, bytes_max);
5929+
if ((bytes = picoquic_frames_varint_skip(bytes, bytes_max)) != NULL) {
5930+
bytes = picoquic_frames_varint_skip(bytes, bytes_max);
5931+
}
59095932
return bytes;
59105933
}
59115934

59125935
const uint8_t* picoquic_parse_path_cid_blocked_frame(const uint8_t* bytes, const uint8_t* bytes_max,
5913-
uint64_t* max_path_id)
5936+
uint64_t* unique_path_id, uint64_t * next_sequence_number)
59145937
{
5915-
bytes = picoquic_frames_varint_decode(bytes, bytes_max, max_path_id);
5938+
if ((bytes = picoquic_frames_varint_decode(bytes, bytes_max, unique_path_id)) != NULL) {
5939+
bytes = picoquic_frames_varint_decode(bytes, bytes_max, next_sequence_number);
5940+
}
59165941
return bytes;
59175942
}
59185943

59195944
const uint8_t* picoquic_decode_path_cid_blocked_frame(const uint8_t* bytes, const uint8_t* bytes_max,
59205945
picoquic_cnx_t* cnx)
59215946
{
5922-
uint64_t path_id;
5947+
uint64_t unique_path_id = 0;
5948+
uint64_t next_sequence_number = 0;
59235949

59245950
/* This code assumes that the frame type is already skipped */
59255951

@@ -5928,7 +5954,7 @@ const uint8_t* picoquic_decode_path_cid_blocked_frame(const uint8_t* bytes, cons
59285954
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_FRAME_FORMAT_ERROR,
59295955
picoquic_frame_type_path_cid_blocked, "multipath extension not negotiated");
59305956
}
5931-
else if ((bytes = picoquic_parse_path_cid_blocked_frame(bytes, bytes_max, &path_id)) == NULL) {
5957+
else if ((bytes = picoquic_parse_path_cid_blocked_frame(bytes, bytes_max, &unique_path_id, &next_sequence_number)) == NULL) {
59325958
/* Bad frame encoding */
59335959
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_FRAME_FORMAT_ERROR,
59345960
picoquic_frame_type_path_cid_blocked, "bad path blocked frame");
@@ -5941,10 +5967,11 @@ int picoquic_path_cid_blocked_frame_needs_repeat(picoquic_cnx_t* cnx, const uint
59415967
{
59425968
int ret = 0;
59435969
uint64_t unique_path_id = 0;
5970+
uint64_t next_sequence_number = 0;
59445971

59455972
*no_need_to_repeat = 0;
59465973

5947-
if ((bytes = picoquic_parse_path_cid_blocked_frame(bytes, bytes_max, &unique_path_id)) == NULL) {
5974+
if ((bytes = picoquic_parse_path_cid_blocked_frame(bytes, bytes_max, &unique_path_id, &next_sequence_number)) == NULL) {
59485975
/* Malformed frame, do not retransmit */
59495976
*no_need_to_repeat = 1;
59505977
}
@@ -5960,6 +5987,15 @@ int picoquic_path_cid_blocked_frame_needs_repeat(picoquic_cnx_t* cnx, const uint
59605987
/* the blocked frame was already acknowledged */
59615988
*no_need_to_repeat = 1;
59625989
}
5990+
else {
5991+
uint64_t current_next_number = picoquic_path_cid_next_sequence_number(cnx->path[path_index]);
5992+
5993+
if (current_next_number > next_sequence_number)
5994+
{
5995+
/* New CID is now available */
5996+
*no_need_to_repeat = 1;
5997+
}
5998+
}
59635999
}
59646000
return ret;
59656001
}
@@ -5969,8 +6005,9 @@ int picoquic_process_ack_of_path_cid_blocked_frame(picoquic_cnx_t* cnx, const ui
59696005
{
59706006
int ret = 0;
59716007
uint64_t unique_path_id = 0;
6008+
uint64_t next_sequence_number = 0;
59726009

5973-
const uint8_t* bytes_next = picoquic_parse_path_cid_blocked_frame(bytes, bytes + bytes_max, &unique_path_id);
6010+
const uint8_t* bytes_next = picoquic_parse_path_cid_blocked_frame(bytes, bytes + bytes_max, &unique_path_id, &next_sequence_number);
59746011

59756012
if (bytes_next != NULL) {
59766013
/* Find the path context for the path ID */
@@ -6864,7 +6901,7 @@ int picoquic_skip_frame(const uint8_t* bytes, size_t bytes_maxsize, size_t* cons
68646901
*pure_ack = 0;
68656902
break;
68666903
case picoquic_frame_type_path_cid_blocked:
6867-
bytes = picoquic_skip_paths_blocked_frame(bytes, bytes_max);
6904+
bytes = picoquic_skip_path_cid_blocked_frame(bytes, bytes_max);
68686905
*pure_ack = 0;
68696906
break;
68706907
case picoquic_frame_type_bdp:

picoquic/logger.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,9 +1500,11 @@ size_t textlog_path_cid_blocked_frame(FILE* F, const uint8_t* bytes, size_t byte
15001500
const uint8_t* bytes0 = bytes;
15011501
uint64_t frame_id = 0;
15021502
uint64_t path_id;
1503+
uint64_t next_sequence_number;
15031504
size_t byte_index = 0;
15041505
if ((bytes = picoquic_frames_varint_decode(bytes, bytes_end, &frame_id)) == NULL ||
1505-
(bytes = picoquic_frames_varint_decode(bytes, bytes_end, &path_id)) == NULL) {
1506+
(bytes = picoquic_frames_varint_decode(bytes, bytes_end, &path_id)) == NULL ||
1507+
(bytes = picoquic_frames_varint_decode(bytes, bytes_end, &next_sequence_number)) == NULL) {
15061508
/* log format error */
15071509
fprintf(F, " Malformed %s frame: ", textlog_frame_names(frame_id));
15081510
/* log format error */
@@ -1516,9 +1518,9 @@ size_t textlog_path_cid_blocked_frame(FILE* F, const uint8_t* bytes, size_t byte
15161518
byte_index = bytes_max;
15171519
}
15181520
else {
1519-
fprintf(F, " %s, path_id: %" PRIu64 "\n",
1521+
fprintf(F, " %s, path_id: %" PRIu64 ", next_sequence_number: %" PRIu64 "\n",
15201522
textlog_frame_names(picoquic_frame_type_path_cid_blocked),
1521-
path_id);
1523+
path_id, next_sequence_number);
15221524
byte_index = (bytes - bytes0);
15231525
}
15241526
return byte_index;

picoquic/picoquic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ extern "C" {
137137

138138
#define PICOQUIC_TRANSPORT_APPLICATION_ABANDON (0x4150504C4142414E)
139139
#define PICOQUIC_TRANSPORT_RESOURCE_LIMIT_REACHED (0x5245534C494D4954)
140+
#define PICOQUIC_TRANSPORT_UNSTABLE_INTERFACE (0x554e5f494e5446)
141+
#define PICOQUIC_TRANSPORT_NO_CID_AVAILABLE (0x4e4f5f4349445f)
140142

141143
#define PICOQUIC_MAX_PACKET_SIZE 1536
142144
#define PICOQUIC_INITIAL_MTU_IPV4 1252

picoquic/picoquic_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ typedef uint64_t picoquic_tp_enum;
588588
#define picoquic_tp_grease_quic_bit 0x2ab2
589589
#define picoquic_tp_version_negotiation 0x11
590590
#define picoquic_tp_enable_bdp_frame 0xebd9 /* per draft-kuhn-quic-0rtt-bdp-09 */
591-
#define picoquic_tp_initial_max_path_id 0x0f739bbc1b666d0cull /* per draft quic multipath 12 */
591+
#define picoquic_tp_initial_max_path_id 0x0f739bbc1b666d0dull /* per draft quic multipath 12 */
592592
#define picoquic_tp_address_discovery 0x9f81a176 /* per draft-seemann-quic-address-discovery */
593593

594594
/* Callback for converting binary log to quic log at the end of a connection.

picoquictest/binlog_ref.log

1 Byte
Binary file not shown.

picoquictest/binlog_ref.qlog

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
"frame_type": "path_retire_connection_id", "path_id": 0, "sequence_number": 2}]}],
8585
[0, "transport", "packet_sent", { "packet_type": "1RTT", "header": { "packet_size": 5, "packet_number": 39, "dcid": "01020304" }, "frames": [{
8686
"frame_type": "paths_blocked", "max_path_id": 17}]}],
87-
[0, "transport", "packet_sent", { "packet_type": "1RTT", "header": { "packet_size": 5, "packet_number": 40, "dcid": "01020304" }, "frames": [{
88-
"frame_type": "path_cid_blocked", "path_id": 7}]}],
87+
[0, "transport", "packet_sent", { "packet_type": "1RTT", "header": { "packet_size": 6, "packet_number": 40, "dcid": "01020304" }, "frames": [{
88+
"frame_type": "path_cid_blocked", "path_id": 7, "next_sequence_number": 1}]}],
8989
[0, "transport", "packet_sent", { "packet_type": "1RTT", "header": { "packet_size": 12, "packet_number": 41, "dcid": "01020304" }, "frames": [{
9090
"frame_type": "bdp", "lifetime": 1, "bytes_in_flight": 2, "min_rtt": 3, "ip": "0a000001"}]}],
9191
[0, "transport", "packet_sent", { "packet_type": "1RTT", "header": { "packet_size": 11, "packet_number": 42, "dcid": "01020304" }, "frames": [{

picoquictest/log_test_ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
path_retire_connection_id[1, 7]: 0x0102030405060708, a1a2a3a4a5a6a7a8a9aaabacadaeafb0
4141
path_retire_connection_id[0, 2]
4242
paths_blocked, max_path_id: 17
43-
path_cid_blocked, path_id: 7
43+
path_cid_blocked, path_id: 7, next_sequence_number: 1
4444
bdp_frame, lifetime: 1, bytes_in_flight: 2, min_rtt: 3, ip: 0a000001
4545
observed_address_v4, sequence: 1, addr: 1.2.3.4, port: 4660
4646
observed_address_v6, sequence: 2, addr: 102:304:506:708:90a:b0c:d0e:f00, port: 17767

picoquictest/log_tp_test_ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
0102030405060708: Extension type: 1 (idle_timeout), length 1, 1e
5757
0102030405060708: Extension type: 3 (max_packet_size), length 2, 45c8
5858
0102030405060708: Extension type: 15 (hcid), length 8, 0203040506070809
59-
0102030405060708: Extension type: 1113404765106498828 (initial_max_path_id), length 1, 04
59+
0102030405060708: Extension type: 1113404765106498829 (initial_max_path_id), length 1, 04
6060

6161
0102030405060708: Extension list (36 bytes):
6262
0102030405060708: Extension type: 1 (idle_timeout), length 2, 400a

picoquictest/skip_frame_test.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static uint8_t test_frame_type_path_cid_blocked[] = {
329329
(uint8_t)(0x80 | (picoquic_frame_type_path_cid_blocked >> 24)), (uint8_t)(picoquic_frame_type_path_cid_blocked >> 16),
330330
(uint8_t)(picoquic_frame_type_path_cid_blocked >> 8), (uint8_t)(picoquic_frame_type_path_cid_blocked & 0xFF),
331331
0x07, /* path id = 7 */
332+
0x01 /* next sequence number = 1 */
332333
};
333334

334335
static uint8_t test_frame_observed_address_v4[] = {
@@ -1560,7 +1561,7 @@ uint8_t* picoquic_format_path_available_or_standby_frame(
15601561
uint8_t* picoquic_format_paths_blocked_frame(
15611562
uint8_t* bytes, const uint8_t* bytes_max, uint64_t max_path_id, int* more_data);
15621563
uint8_t* picoquic_format_path_cid_blocked_frame(
1563-
uint8_t* bytes, const uint8_t* bytes_max, uint64_t max_path_id, int* more_data);
1564+
uint8_t* bytes, const uint8_t* bytes_max, uint64_t max_path_id, uint64_t next_sequence_number, int* more_data);
15641565

15651566
int frames_format_test()
15661567
{
@@ -1632,7 +1633,7 @@ int frames_format_test()
16321633
FRAME_FORMAT_TEST(picoquic_format_path_available_or_standby_frame, bytes, bytes_max, picoquic_frame_type_path_available, 1, 17, &more_data);
16331634
FRAME_FORMAT_TEST(picoquic_format_max_path_id_frame, bytes, bytes_max, 123, &more_data);
16341635
FRAME_FORMAT_TEST(picoquic_format_paths_blocked_frame, bytes, bytes_max, 123, &more_data);
1635-
FRAME_FORMAT_TEST(picoquic_format_path_cid_blocked_frame, bytes, bytes_max, 123, &more_data);
1636+
FRAME_FORMAT_TEST(picoquic_format_path_cid_blocked_frame, bytes, bytes_max, 123, 0, &more_data);
16361637
FRAME_FORMAT_TEST(picoquic_format_observed_address_frame, bytes, bytes_max, picoquic_frame_type_observed_address_v4, 13, addr_bytes, 4433, &more_data);
16371638
}
16381639

0 commit comments

Comments
 (0)