From: Matus Fabian Date: Thu, 10 Jul 2025 11:44:07 +0000 (-0400) Subject: hsa: http cli server add http1-only option X-Git-Tag: v26.02-rc0~182 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F43430%2F1;p=vpp.git hsa: http cli server add http1-only option Type: improvement Change-Id: I2d3656ee7e154a44efab7501399de4b1fc696dc7 Signed-off-by: Matus Fabian --- diff --git a/extras/hs-test/http1_test.go b/extras/hs-test/http1_test.go index e3a70023370..6bc5c987495 100644 --- a/extras/hs-test/http1_test.go +++ b/extras/hs-test/http1_test.go @@ -288,7 +288,7 @@ func HttpCliTest(s *VethsSuite) { func HttpCliTlsTest(s *VethsSuite) { uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1 - s.Containers.ServerVpp.VppInstance.Vppctl("http cli server uri " + uri) + s.Containers.ServerVpp.VppInstance.Vppctl("http cli server http1-only uri " + uri) o := s.Containers.ClientVpp.VppInstance.Vppctl("http cli client" + " uri " + uri + " query /show/version") diff --git a/src/plugins/hs_apps/http_cli.c b/src/plugins/hs_apps/http_cli.c index 40acf6a1635..6fddd5e11c2 100644 --- a/src/plugins/hs_apps/http_cli.c +++ b/src/plugins/hs_apps/http_cli.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,22 @@ typedef struct u8 *resp_headers_buf; } hcs_session_t; +#define foreach_hcs_listener_flags _ (HTTP1_ONLY) + +typedef enum hcs_listener_flags_bit_ +{ +#define _(sym) HCS_LISTENER_F_BIT_##sym, + foreach_hcs_listener_flags +#undef _ +} hcs_listener_flags_bit_t; + +typedef enum hcs_listener_flags_ +{ +#define _(sym) HCS_LISTENER_F_##sym = 1 << HCS_LISTENER_F_BIT_##sym, + foreach_hcs_listener_flags +#undef _ +} __clib_packed hcs_listener_flags_t; + typedef struct { hcs_session_t **sessions; @@ -70,6 +87,7 @@ typedef struct u32 fifo_size; u8 *uri; vlib_main_t *vlib_main; + u8 flags; /* hash table to store uri -> uri map pool index */ uword *index_by_uri; @@ -649,6 +667,8 @@ hcs_listen () &a->sep_ext, TRANSPORT_ENDPT_EXT_CFG_CRYPTO, sizeof (transport_endpt_crypto_cfg_t)); ext_cfg->crypto.ckpair_index = hcm->ckpair_index; + if (hcm->flags & HCS_LISTENER_F_HTTP1_ONLY) + ext_cfg->crypto.alpn_protos[0] = TLS_ALPN_PROTO_HTTP_1_1; } rv = vnet_listen (a); @@ -774,6 +794,8 @@ hcs_create_command_fn (vlib_main_t *vm, unformat_input_t *input, ; else if (unformat (line_input, "secret %lu", &hcm->appns_secret)) ; + else if (unformat (line_input, "http1-only")) + hcm->flags |= HCS_LISTENER_F_HTTP1_ONLY; else if (unformat (line_input, "listener")) { if (unformat (line_input, "add"))