Skip to content

Commit

Permalink
[+] add path cids blocked trigger logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanmei-Liu committed Jan 28, 2025
1 parent 167bf7a commit 146b53b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/xquic/xqc_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ typedef enum {
XQC_PATH_NO_ERROR = 0x0,
XQC_PATH_APPLICATION_ABANDON = 0x004150504142414E, /* Path abandon error code: APPLICATION_ABANDON */
XQC_PATH_RESOURCE_LIMIT_REACHED = 0x0052534C494D4954, /* Path abandon error code: RESOURCE_LIMIT_REACHED */
XQC_PATH_UNSTABLE_INTERFACE = 0x00554e5f494e5446, /* Path abandon error code: UNSTABLE_INTERFACE */
XQC_PATH_NO_CID_AVAILABLE = 0x004e4f5f4349445f, /* Path abandon error code: NO_CID_AVAILABLE */
} xqc_multipath_error_t;

#define QPACK_ERR_START 900
Expand Down
15 changes: 13 additions & 2 deletions src/transport/xqc_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ xqc_engine_process_conn(xqc_connection_t *conn, xqc_usec_t now)
xqc_log(conn->log, XQC_LOG_DEBUG, "|conn:%p|state:%s|flag:%s|now:%ui|",
conn, xqc_conn_state_2_str(conn->conn_state), xqc_conn_flag_2_str(conn, conn->conn_flag), now);

int ret;
int ret = 0, rc = 0;
xqc_bool_t wait_scid, wait_dcid;

xqc_conn_timer_expire(conn, now);
Expand Down Expand Up @@ -733,11 +733,22 @@ xqc_engine_process_conn(xqc_connection_t *conn, xqc_usec_t now)
}

if (conn->enable_multipath) {
ret = xqc_conn_get_available_path_id(conn, NULL);
if ((conn->conn_flag & XQC_CONN_FLAG_MP_WAIT_MP_READY)
&& xqc_conn_get_available_path_id(conn, NULL) == XQC_OK)
&& ret == XQC_OK)
{
conn->conn_flag |= XQC_CONN_FLAG_MP_READY_NOTIFY;
conn->conn_flag &= ~XQC_CONN_FLAG_MP_WAIT_MP_READY;
} else if (ret != XQC_OK) {
/* not enough cid for new path id */
uint64_t path_id = conn->create_path_count;
xqc_cid_set_inner_t *dcid_inner_set = xqc_get_path_cid_set(&conn->dcid_set, path_id);
if (dcid_inner_set && dcid_inner_set->unused_cnt == 0) {
rc = xqc_write_path_cids_blocked_to_packet(conn, path_id);
if (rc) {
xqc_log(conn->log, XQC_LOG_WARN, "|xqc_write_path_cids_blocked_to_packet error|ret:%ui|", ret);
}
}
}

xqc_log(conn->log, XQC_LOG_DEBUG, "|create_path_count:%ui|remote_max_path_id:%ui|",
Expand Down
29 changes: 29 additions & 0 deletions src/transport/xqc_packet_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,35 @@ xqc_write_path_blocked_to_packet(xqc_connection_t *conn, uint64_t max_path_id)
xqc_log(conn->log, XQC_LOG_DEBUG, "|max_path_id:%ui|", max_path_id);
return XQC_OK;

error:
xqc_maybe_recycle_packet_out(packet_out, conn);
return -XQC_EWRITE_PKT;
}


int
xqc_write_path_cids_blocked_to_packet(xqc_connection_t *conn, uint64_t path_id)
{
ssize_t ret = XQC_ERROR;
xqc_packet_out_t *packet_out;
xqc_log(conn->log, XQC_LOG_DEBUG, "|path blocked max_path_id:%ui|", path_id);

packet_out = xqc_write_new_packet(conn, XQC_PTYPE_SHORT_HEADER);
if (packet_out == NULL) {
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_write_new_packet error|");
return -XQC_EWRITE_PKT;
}

ret = xqc_gen_path_cids_blocked_frame(packet_out, path_id);
if (ret < 0) {
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_gen_path_blocked_frame error|");
goto error;
}
packet_out->po_used_size += ret;
xqc_send_queue_move_to_high_pri(&packet_out->po_list, conn->conn_send_queue);
xqc_log(conn->log, XQC_LOG_DEBUG, "|max_path_id:%ui|", path_id);
return XQC_OK;

error:
xqc_maybe_recycle_packet_out(packet_out, conn);
return -XQC_EWRITE_PKT;
Expand Down
2 changes: 2 additions & 0 deletions src/transport/xqc_packet_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ xqc_int_t xqc_write_mp_retire_conn_id_frame_to_packet(xqc_connection_t *conn, ui

int xqc_write_max_path_id_to_packet(xqc_connection_t *conn, uint64_t max_path_id);
int xqc_write_path_blocked_to_packet(xqc_connection_t *conn, uint64_t max_path_id);
int xqc_write_path_cids_blocked_to_packet(xqc_connection_t *conn, uint64_t path_id);

/**
* @brief Get remained space size in packet out buff.
*
Expand Down

0 comments on commit 146b53b

Please sign in to comment.