diff options
author | Florin Coras <fcoras@cisco.com> | 2022-02-11 11:59:04 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-02-11 19:55:17 +0000 |
commit | 360aee3e00c1211840b5a946a274ef1c496d5aa2 (patch) | |
tree | 42d8d7bedb5de3ce76f807fecf44ee742f16e731 /src/plugins/http | |
parent | d37328eb8b255135c9e0599650d994949e61cd27 (diff) |
http: fix support for files larger than u32
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Iad7304c3a8fef14ec85c4240714feb86637411ca
Diffstat (limited to 'src/plugins/http')
-rw-r--r-- | src/plugins/http/http.c | 3 | ||||
-rw-r--r-- | src/plugins/http/http.h | 2 | ||||
-rw-r--r-- | src/plugins/http/http_buffer.c | 16 | ||||
-rw-r--r-- | src/plugins/http/http_buffer.h | 10 |
4 files changed, 16 insertions, 15 deletions
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c index 4ac136b7b0d..d407d9dfdb0 100644 --- a/src/plugins/http/http.c +++ b/src/plugins/http/http.c @@ -192,6 +192,7 @@ http_ts_accept_callback (session_t *ts) * the fifo is small (under 16K) we set the threshold to it's size, meaning * a notification will be given when the fifo empties. */ + ts = session_get_from_handle (hc->h_tc_session_handle); thresh = clib_min (svm_fifo_size (ts->tx_fifo), HTTP_FIFO_THRESH); svm_fifo_set_deq_thresh (ts->tx_fifo, thresh); @@ -254,7 +255,7 @@ static const char *http_response_template = "HTTP/1.1 200 OK\r\n" "Expires: %U GMT\r\n" "Server: VPP Static\r\n" "Content-Type: %s\r\n" - "Content-Length: %d\r\n\r\n"; + "Content-Length: %lu\r\n\r\n"; static u32 send_data (http_conn_t *hc, u8 *data, u32 length, u32 offset) diff --git a/src/plugins/http/http.h b/src/plugins/http/http.h index 85d43a489e2..8a5731ea592 100644 --- a/src/plugins/http/http.h +++ b/src/plugins/http/http.h @@ -116,7 +116,7 @@ typedef enum http_msg_data_type_ typedef struct http_msg_data_ { http_msg_data_type_t type; - u32 len; + u64 len; u8 data[0]; } http_msg_data_t; diff --git a/src/plugins/http/http_buffer.c b/src/plugins/http/http_buffer.c index 0b031693682..f3dc308dbf8 100644 --- a/src/plugins/http/http_buffer.c +++ b/src/plugins/http/http_buffer.c @@ -28,14 +28,14 @@ typedef struct http_buffer_fifo_ { svm_fifo_t *src; svm_fifo_seg_t *segs; - u32 len; - u32 offset; + u64 len; + u64 offset; } http_buffer_fifo_t; STATIC_ASSERT (sizeof (http_buffer_fifo_t) <= HTTP_BUFFER_DATA_SZ, "buf data"); static void -buf_fifo_init (http_buffer_t *hb, void *data, u32 len) +buf_fifo_init (http_buffer_t *hb, void *data, u64 len) { svm_fifo_t *f = (svm_fifo_t *) data; http_buffer_fifo_t *bf; @@ -65,7 +65,7 @@ buf_fifo_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs) u32 _n_segs = 5; int len; - max_len = clib_max (bf->len - bf->offset, max_len); + max_len = clib_min (bf->len - bf->offset, (u64) max_len); vec_validate (bf->segs, _n_segs); @@ -80,7 +80,7 @@ buf_fifo_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs) return bf->segs; } -static int +static u32 buf_fifo_drain (http_buffer_t *hb, u32 len) { http_buffer_fifo_t *bf = (http_buffer_fifo_t *) &hb->data; @@ -120,7 +120,7 @@ typedef struct http_buffer_ptr_ STATIC_ASSERT (sizeof (http_buffer_ptr_t) <= HTTP_BUFFER_DATA_SZ, "buf data"); static void -buf_ptr_init (http_buffer_t *hb, void *data, u32 len) +buf_ptr_init (http_buffer_t *hb, void *data, u64 len) { svm_fifo_t *f = (svm_fifo_t *) data; http_buffer_ptr_t *bf; @@ -163,7 +163,7 @@ buf_ptr_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs) return &bf->segs[1]; } -static int +static u32 buf_ptr_drain (http_buffer_t *hb, u32 len) { http_buffer_ptr_t *bf = (http_buffer_ptr_t *) &hb->data; @@ -204,7 +204,7 @@ HTTP_BUFFER_REGISTER_VFT (HTTP_BUFFER_PTR, buf_ptr_vft); void http_buffer_init (http_buffer_t *hb, http_buffer_type_t type, svm_fifo_t *f, - u32 data_len) + u64 data_len) { hb->vft = &buf_vfts[type]; hb->vft->init (hb, f, data_len); diff --git a/src/plugins/http/http_buffer.h b/src/plugins/http/http_buffer.h index 5c7569b9e3c..1140be42d6e 100644 --- a/src/plugins/http/http_buffer.h +++ b/src/plugins/http/http_buffer.h @@ -18,7 +18,7 @@ #include <svm/svm_fifo.h> -#define HTTP_BUFFER_DATA_SZ 24 +#define HTTP_BUFFER_DATA_SZ 32 typedef enum http_buffer_type_ { @@ -36,15 +36,15 @@ typedef struct http_buffer_ struct http_buffer_vft_ { - void (*init) (http_buffer_t *, void *data, u32 len); + void (*init) (http_buffer_t *, void *data, u64 len); void (*free) (http_buffer_t *); svm_fifo_seg_t *(*get_segs) (http_buffer_t *, u32 max_len, u32 *n_segs); - int (*drain) (http_buffer_t *, u32 len); + u32 (*drain) (http_buffer_t *, u32 len); u8 (*is_drained) (http_buffer_t *); }; void http_buffer_init (http_buffer_t *hb, http_buffer_type_t type, - svm_fifo_t *f, u32 data_len); + svm_fifo_t *f, u64 data_len); static inline void http_buffer_free (http_buffer_t *hb) @@ -59,7 +59,7 @@ http_buffer_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs) return hb->vft->get_segs (hb, max_len, n_segs); } -static inline int +static inline u32 http_buffer_drain (http_buffer_t *hb, u32 len) { return hb->vft->drain (hb, len); |