Skip to content

Commit

Permalink
[+] add resource limit for max path id update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanmei-Liu committed Dec 4, 2024
1 parent e7935eb commit 2fd8e79
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/transport/xqc_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,10 @@ xqc_conn_create(xqc_engine_t *engine, xqc_cid_t *dcid, xqc_cid_t *scid,
xc->conn_settings.init_max_path_id = XQC_DEFAULT_INIT_MAX_PATH_ID;
}

if (xc->max_paths_count == 0) {
xc->max_paths_count = XQC_MAX_PATHS_COUNT;
}

if (xc->conn_settings.probing_pkt_out_size == 0) {
xc->conn_settings.probing_pkt_out_size = engine->default_conn_settings.probing_pkt_out_size;
}
Expand Down
1 change: 1 addition & 0 deletions src/transport/xqc_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ struct xqc_connection_s {
uint32_t create_path_count;
uint32_t validated_path_count;
uint32_t active_path_count;
uint64_t max_paths_count;

uint64_t curr_max_path_id;
uint64_t local_max_path_id;
Expand Down
16 changes: 4 additions & 12 deletions src/transport/xqc_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2070,18 +2070,10 @@ xqc_process_path_blocked_frame(xqc_connection_t *conn, xqc_packet_in_t *packet_i
return XQC_OK;
}

uint64_t pre_max_path_id = conn->local_max_path_id;
conn->local_max_path_id += (conn->local_max_path_id + 1) / 2;
if (xqc_conn_add_path_cid_sets(conn, pre_max_path_id + 1, conn->local_max_path_id) != XQC_OK) {
xqc_log(conn->log, XQC_LOG_ERROR, "|add_path_cid_sets_error|");
return -XQC_EMALLOC;
}

ret = xqc_write_max_path_id_to_packet(conn, conn->local_max_path_id);
if (ret != XQC_OK) {
xqc_log(conn->log, XQC_LOG_ERROR,
"|xqc_write_max_path_id_to_packet error|");
return ret;
if (xqc_conn_check_path_id_blocked(conn) /* check whether all path ids have been used */
&& (uint64_t)conn->create_path_count < conn->max_paths_count) /* check whether touched path resource limit */
{
ret = xqc_conn_update_max_path_id(conn);
}

return ret;
Expand Down
32 changes: 32 additions & 0 deletions src/transport/xqc_multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,5 +1641,37 @@ xqc_conn_trigger_cid_retirement_on_path(xqc_engine_t *engine, const xqc_cid_t *s
"|xqc_path_last_cid_retirement error|scid:%s|path_id:%ui|", xqc_scid_str(engine, scid), path_id);
}

return ret;
}

xqc_bool_t
xqc_conn_check_path_id_blocked(xqc_connection_t *conn)
{
if (conn->create_path_count >= conn->local_max_path_id + 1) {
return XQC_TRUE;
}

return XQC_FALSE;
}

xqc_int_t
xqc_conn_update_max_path_id(xqc_connection_t *conn)
{
xqc_int_t ret = XQC_OK;
uint64_t pre_max_path_id = conn->local_max_path_id;
conn->local_max_path_id += (conn->local_max_path_id + 1) / 2;
conn->local_max_path_id = xqc_max(conn->local_max_path_id, conn->max_paths_count);
if (xqc_conn_add_path_cid_sets(conn, pre_max_path_id + 1, conn->local_max_path_id) != XQC_OK) {
xqc_log(conn->log, XQC_LOG_ERROR, "|add_path_cid_sets_error|");
return -XQC_EMALLOC;
}

ret = xqc_write_max_path_id_to_packet(conn, conn->local_max_path_id);
if (ret != XQC_OK) {
xqc_log(conn->log, XQC_LOG_ERROR,
"|xqc_write_max_path_id_to_packet error|");
return ret;
}

return ret;
}
2 changes: 2 additions & 0 deletions src/transport/xqc_multipath.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ double xqc_path_recent_loss_rate(xqc_path_ctx_t *path);

double xqc_conn_recent_loss_rate(xqc_connection_t *conn);

xqc_bool_t xqc_conn_check_path_id_blocked(xqc_connection_t *conn);
xqc_int_t xqc_conn_update_max_path_id(xqc_connection_t *conn);

#endif /* XQC_MULTIPATH_H */

Expand Down

0 comments on commit 2fd8e79

Please sign in to comment.