aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/http_static/http_static.c
diff options
context:
space:
mode:
authorSemir Sionek <ssionek@cisco.com>2025-01-17 10:06:23 -0500
committerFlorin Coras <florin.coras@gmail.com>2025-01-23 18:30:28 +0000
commit5e94895dfd7d597a88965e6b5c1d2a3bc6ffe67e (patch)
tree488c998e057296d7fecefb11c1756289e58f34d5 /src/plugins/http_static/http_static.c
parent7267149267fae4bb814af441fabb42767c1a720d (diff)
http_static: introduce max-body-size parameter
Introduce the max-body-size parameter to put a limit on how big of a POST request can the static server take (and how big of a memory allocation that causes). Type: improvement Change-Id: I93cdeaf38dabe2850665e92bedbaa0545c375214 Signed-off-by: Semir Sionek <ssionek@cisco.com>
Diffstat (limited to 'src/plugins/http_static/http_static.c')
-rw-r--r--src/plugins/http_static/http_static.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/plugins/http_static/http_static.c b/src/plugins/http_static/http_static.c
index 464fd27e90d..7a12f37b8d3 100644
--- a/src/plugins/http_static/http_static.c
+++ b/src/plugins/http_static/http_static.c
@@ -67,7 +67,7 @@ hss_register_url_handler (hss_url_handler_fn fp, const char *url,
static int
hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos,
u32 private_segment_size, u8 *www_root, u8 *uri, u32 max_age,
- u32 keepalive_timeout)
+ u32 keepalive_timeout, u64 max_body_size)
{
hss_main_t *hsm = &hss_main;
int rv;
@@ -79,6 +79,7 @@ hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos,
hsm->www_root = format (0, "%s%c", www_root, 0);
hsm->uri = format (0, "%s%c", uri, 0);
hsm->max_age = max_age;
+ hsm->max_body_size = max_body_size;
hsm->keepalive_timeout = keepalive_timeout;
if (vec_len (hsm->www_root) < 2)
@@ -119,7 +120,8 @@ vl_api_http_static_enable_v2_t_handler (vl_api_http_static_enable_v2_t *mp)
rv = hss_enable_api (ntohl (mp->fifo_size), ntohl (mp->cache_size_limit),
ntohl (mp->prealloc_fifos),
ntohl (mp->private_segment_size), mp->www_root, mp->uri,
- ntohl (mp->max_age), HSS_DEFAULT_KEEPALIVE_TIMEOUT);
+ ntohl (mp->max_age), HSS_DEFAULT_KEEPALIVE_TIMEOUT,
+ HSS_DEFAULT_MAX_BODY_SIZE);
REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V2_REPLY);
}
@@ -138,11 +140,32 @@ vl_api_http_static_enable_v3_t_handler (vl_api_http_static_enable_v3_t *mp)
rv = hss_enable_api (ntohl (mp->fifo_size), ntohl (mp->cache_size_limit),
ntohl (mp->prealloc_fifos),
ntohl (mp->private_segment_size), mp->www_root, mp->uri,
- ntohl (mp->max_age), ntohl (mp->keepalive_timeout));
+ ntohl (mp->max_age), ntohl (mp->keepalive_timeout),
+ HSS_DEFAULT_MAX_BODY_SIZE);
REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V3_REPLY);
}
+/* API message handler */
+static void
+vl_api_http_static_enable_v4_t_handler (vl_api_http_static_enable_v4_t *mp)
+{
+ vl_api_http_static_enable_v4_reply_t *rmp;
+ hss_main_t *hsm = &hss_main;
+ int rv;
+
+ mp->uri[ARRAY_LEN (mp->uri) - 1] = 0;
+ mp->www_root[ARRAY_LEN (mp->www_root) - 1] = 0;
+
+ rv = hss_enable_api (ntohl (mp->fifo_size), ntohl (mp->cache_size_limit),
+ ntohl (mp->prealloc_fifos),
+ ntohl (mp->private_segment_size), mp->www_root, mp->uri,
+ ntohl (mp->max_age), ntohl (mp->keepalive_timeout),
+ ntohl (mp->max_body_size));
+
+ REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V4_REPLY);
+}
+
#include <http_static/http_static.api.c>
static clib_error_t *
hss_api_init (vlib_main_t *vm)