diff options
author | Aritra Basu <aritrbas@cisco.com> | 2024-09-09 21:47:26 -0700 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-09-13 21:22:10 +0000 |
commit | 6f45f5465f219cb55f0f095c420aae469e550f7f (patch) | |
tree | baaa8a167db282951f1eae9cd6bea93272ff8080 | |
parent | 6fbe913e45ff252f5d6497eb81cdcf139afc0d5d (diff) |
http: update body_len from u32 to u64
Type: improvement
Change-Id: I381541fb180d6d6ba42e4d231d22a73c5d33ef65
Signed-off-by: Aritra Basu <aritrbas@cisco.com>
-rw-r--r-- | src/plugins/hs_apps/http_client_cli.c | 6 | ||||
-rw-r--r-- | src/plugins/hs_apps/http_simple_post.c | 19 | ||||
-rw-r--r-- | src/plugins/hs_apps/http_tps.c | 4 | ||||
-rw-r--r-- | src/plugins/http/http.c | 15 | ||||
-rw-r--r-- | src/plugins/http/http.h | 6 | ||||
-rw-r--r-- | src/plugins/http/http_plugin.rst | 8 | ||||
-rw-r--r-- | src/plugins/http_static/http_static.h | 2 | ||||
-rw-r--r-- | src/plugins/http_static/static_server.c | 18 |
8 files changed, 48 insertions, 30 deletions
diff --git a/src/plugins/hs_apps/http_client_cli.c b/src/plugins/hs_apps/http_client_cli.c index afa173c98df..4b8ef173bd9 100644 --- a/src/plugins/hs_apps/http_client_cli.c +++ b/src/plugins/hs_apps/http_client_cli.c @@ -35,7 +35,7 @@ typedef struct u32 thread_index; u32 rx_offset; u32 vpp_session_index; - u32 to_recv; + u64 to_recv; u8 is_closed; http_header_t *req_headers; } hcc_session_t; @@ -261,7 +261,7 @@ hcc_ts_rx_callback (session_t *ts) u32 max_deq = svm_fifo_max_dequeue (ts->rx_fifo); u32 n_deq = clib_min (hs->to_recv, max_deq); - u32 curr = vec_len (hcm->http_response); + u64 curr = vec_len (hcm->http_response); rv = svm_fifo_dequeue (ts->rx_fifo, n_deq, hcm->http_response + curr); if (rv < 0) { @@ -275,7 +275,7 @@ hcc_ts_rx_callback (session_t *ts) vec_set_len (hcm->http_response, curr + n_deq); ASSERT (hs->to_recv >= rv); hs->to_recv -= rv; - HCC_DBG ("app rcvd %d, remains %d", rv, hs->to_recv); + HCC_DBG ("app rcvd %d, remains %llu", rv, hs->to_recv); done: if (hs->to_recv == 0) diff --git a/src/plugins/hs_apps/http_simple_post.c b/src/plugins/hs_apps/http_simple_post.c index 0c2b30ad25c..6212eac1c97 100644 --- a/src/plugins/hs_apps/http_simple_post.c +++ b/src/plugins/hs_apps/http_simple_post.c @@ -36,7 +36,7 @@ typedef struct u8 *target; u8 *headers_buf; u8 *data; - u32 data_offset; + u64 data_offset; hsp_worker_t *wrk; u8 *http_response; u8 is_file; @@ -86,6 +86,8 @@ hsp_session_connected_callback (u32 app_index, u32 hsp_session_index, hsp_worker_t *wrk; http_header_t *headers = 0; http_msg_t msg; + u64 to_send; + u32 n_enq; int rv; if (err) @@ -166,8 +168,12 @@ hsp_session_connected_callback (u32 app_index, u32 hsp_session_index, hspm->headers_buf); ASSERT (rv == msg.data.headers_len); - rv = svm_fifo_enqueue (s->tx_fifo, vec_len (hspm->data), hspm->data); - if (rv != vec_len (hspm->data)) + to_send = vec_len (hspm->data); + n_enq = clib_min (svm_fifo_size (s->tx_fifo), to_send); + + rv = svm_fifo_enqueue (s->tx_fifo, n_enq, hspm->data); + + if (rv < to_send) { hspm->data_offset = (rv > 0) ? rv : 0; svm_fifo_add_want_deq_ntf (s->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF); @@ -263,11 +269,14 @@ static int hsp_tx_callback (session_t *s) { hsp_main_t *hspm = &hsp_main; - u32 to_send; + u64 to_send; + u32 n_enq; int rv; to_send = vec_len (hspm->data) - hspm->data_offset; - rv = svm_fifo_enqueue (s->tx_fifo, to_send, hspm->data + hspm->data_offset); + n_enq = clib_min (svm_fifo_size (s->tx_fifo), to_send); + + rv = svm_fifo_enqueue (s->tx_fifo, n_enq, hspm->data + hspm->data_offset); if (rv <= 0) { diff --git a/src/plugins/hs_apps/http_tps.c b/src/plugins/hs_apps/http_tps.c index 583dccb92ac..cdeafa5d54a 100644 --- a/src/plugins/hs_apps/http_tps.c +++ b/src/plugins/hs_apps/http_tps.c @@ -30,8 +30,8 @@ typedef struct u64 data_len; u64 data_offset; u32 vpp_session_index; - u32 left_recv; - u32 total_recv; + u64 left_recv; + u64 total_recv; union { /** threshold after which connection is closed */ diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c index d01ee7f0fc6..4f741c2e6b4 100644 --- a/src/plugins/http/http.c +++ b/src/plugins/http/http.c @@ -379,7 +379,7 @@ static const char *http_error_template = "HTTP/1.1 %s\r\n" static const char *http_response_template = "HTTP/1.1 %s\r\n" "Date: %U GMT\r\n" "Server: %v\r\n" - "Content-Length: %u\r\n" + "Content-Length: %llu\r\n" "%s"; /** @@ -393,7 +393,7 @@ static const char *http_get_request_template = "GET %s HTTP/1.1\r\n" static const char *http_post_request_template = "POST %s HTTP/1.1\r\n" "Host: %v\r\n" "User-Agent: %v\r\n" - "Content-Length: %u\r\n" + "Content-Length: %llu\r\n" "%s"; static u32 @@ -853,7 +853,7 @@ http_identify_message_body (http_conn_t *hc, http_status_code_t *ec) unformat_input_t input; int i, len; u8 *line; - u32 body_len; + u64 body_len; hc->body_len = 0; @@ -895,7 +895,7 @@ http_identify_message_body (http_conn_t *hc, http_status_code_t *ec) HTTP_DBG (0, "%v", line); unformat_init_vector (&input, line); - if (!unformat (&input, "%u", &body_len)) + if (!unformat (&input, "%llu", &body_len)) { clib_warning ("failed to unformat content length value"); *ec = HTTP_STATUS_BAD_REQUEST; @@ -905,7 +905,7 @@ http_identify_message_body (http_conn_t *hc, http_status_code_t *ec) hc->body_len = body_len; hc->body_offset = hc->headers_offset + hc->headers_len + 2; - HTTP_DBG (0, "body length: %u", hc->body_len); + HTTP_DBG (0, "body length: %llu", hc->body_len); HTTP_DBG (0, "body offset: %u", hc->body_offset); return 0; @@ -1013,7 +1013,8 @@ http_state_wait_client_method (http_conn_t *hc, transport_send_params_t *sp) http_msg_t msg; session_t *as; int rv; - u32 len, max_enq, max_deq, body_sent; + u32 len, max_enq, body_sent; + u64 max_deq; rv = http_read_message (hc); @@ -1429,7 +1430,7 @@ http_state_client_io_more_data (http_conn_t *hc, transport_send_params_t *sp) return HTTP_SM_ERROR; } hc->to_recv -= rv; - HTTP_DBG (1, "drained %d from ts; remains %d", rv, hc->to_recv); + HTTP_DBG (1, "drained %d from ts; remains %lu", rv, hc->to_recv); /* Finished transaction: * server back to HTTP_STATE_WAIT_APP_REPLY diff --git a/src/plugins/http/http.h b/src/plugins/http/http.h index 35e7d4dcfb6..5f74edb5e47 100644 --- a/src/plugins/http/http.h +++ b/src/plugins/http/http.h @@ -358,7 +358,7 @@ typedef struct http_msg_data_ u32 headers_offset; u32 headers_len; u32 body_offset; - u32 body_len; + u64 body_len; u8 data[0]; } http_msg_data_t; @@ -400,7 +400,7 @@ typedef struct http_tc_ u8 *rx_buf; u32 rx_buf_offset; http_buffer_t tx_buf; - u32 to_recv; + u64 to_recv; u32 bytes_dequeued; u32 control_data_len; /* start line + headers + empty line */ http_target_form_t target_form; @@ -411,7 +411,7 @@ typedef struct http_tc_ u32 headers_offset; u32 headers_len; u32 body_offset; - u32 body_len; + u64 body_len; u16 status_code; } http_conn_t; diff --git a/src/plugins/http/http_plugin.rst b/src/plugins/http/http_plugin.rst index feb2c7fe039..56da3a810b9 100644 --- a/src/plugins/http/http_plugin.rst +++ b/src/plugins/http/http_plugin.rst @@ -152,7 +152,7 @@ We will add following members to our session context structure: typedef struct { /* ... */ - u32 to_recv; + u64 to_recv; u8 *resp_body; } session_ctx_t; @@ -174,7 +174,7 @@ Now we can start reading body content, following block of code could be executed /* dequeue */ u32 n_deq = svm_fifo_max_dequeue (ts->rx_fifo); /* current offset */ - u32 curr = vec_len (ctx->resp_body); + u64 curr = vec_len (ctx->resp_body); rv = svm_fifo_dequeue (ts->rx_fifo, n_deq, ctx->resp_body + curr); ASSERT (rv == n_deq); /* update length of the vector */ @@ -464,7 +464,7 @@ We will add following members to our session context structure: typedef struct { /* ... */ - u32 to_recv; + u64 to_recv; u8 *resp_body; } session_ctx_t; @@ -487,7 +487,7 @@ Now we can start reading body content, following block of code could be executed u32 max_deq = svm_fifo_max_dequeue (ts->rx_fifo); u32 n_deq = clib_min (to_recv, max_deq); /* current offset */ - u32 curr = vec_len (ctx->resp_body); + u64 curr = vec_len (ctx->resp_body); rv = svm_fifo_dequeue (ts->rx_fifo, n_deq, ctx->resp_body + curr); if (rv < 0 || rv != n_deq) { diff --git a/src/plugins/http_static/http_static.h b/src/plugins/http_static/http_static.h index f9364801a71..bee79090d2b 100644 --- a/src/plugins/http_static/http_static.h +++ b/src/plugins/http_static/http_static.h @@ -47,7 +47,7 @@ typedef struct /** Data length */ u64 data_len; /** Current data send offset */ - u32 data_offset; + u64 data_offset; /** Need to free data in detach_cache_entry */ int free_data; /** File cache pool index */ diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index 5515a98b446..9d9a68f7d02 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -87,6 +87,8 @@ start_send_data (hss_session_t *hs, http_status_code_t status) http_msg_t msg; session_t *ts; u8 *headers_buf = 0; + u32 n_enq; + u64 to_send; int rv; ts = session_get (hs->vpp_session_index, hs->thread_index); @@ -147,9 +149,12 @@ start_send_data (hss_session_t *hs, http_status_code_t status) if (!msg.data.body_len) goto done; - rv = svm_fifo_enqueue (ts->tx_fifo, hs->data_len, hs->data); + to_send = hs->data_len; + n_enq = clib_min (svm_fifo_size (ts->tx_fifo), to_send); - if (rv != hs->data_len) + rv = svm_fifo_enqueue (ts->tx_fifo, n_enq, hs->data); + + if (rv < to_send) { hs->data_offset = (rv > 0) ? rv : 0; svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF); @@ -598,7 +603,8 @@ static int hss_ts_tx_callback (session_t *ts) { hss_session_t *hs; - u32 to_send; + u32 n_enq; + u64 to_send; int rv; hs = hss_session_get (ts->thread_index, ts->opaque); @@ -606,7 +612,9 @@ hss_ts_tx_callback (session_t *ts) return 0; to_send = hs->data_len - hs->data_offset; - rv = svm_fifo_enqueue (ts->tx_fifo, to_send, hs->data + hs->data_offset); + n_enq = clib_min (svm_fifo_size (ts->tx_fifo), to_send); + + rv = svm_fifo_enqueue (ts->tx_fifo, n_enq, hs->data + hs->data_offset); if (rv <= 0) { @@ -993,7 +1001,7 @@ format_hss_session (u8 *s, va_list *args) hss_session_t *hs = va_arg (*args, hss_session_t *); int __clib_unused verbose = va_arg (*args, int); - s = format (s, "\n path %s, data length %u, data_offset %u", + s = format (s, "\n path %s, data length %llu, data_offset %llu", hs->path ? hs->path : (u8 *) "[none]", hs->data_len, hs->data_offset); return s; |