Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] use llhttp as default HTTP parser #9033

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions bazel/external/llhttp.BUILD
@@ -0,0 +1,13 @@
licenses(["notice"]) # Apache 2

cc_library(
name = "llhttp",
srcs = [
"src/api.c",
"src/http.c",
"src/llhttp.c",
],
hdrs = ["include/llhttp.h"],
includes = ["include"],
visibility = ["//visibility:public"],
)
11 changes: 11 additions & 0 deletions bazel/repositories.bzl
Expand Up @@ -168,6 +168,7 @@ def envoy_dependencies(skip_targets = []):
_com_github_moonjit_moonjit()
_com_github_nghttp2_nghttp2()
_com_github_nodejs_http_parser()
_com_github_nodejs_llhttp()
_com_github_tencent_rapidjson()
_com_google_absl()
_com_google_googletest()
Expand Down Expand Up @@ -439,6 +440,16 @@ def _com_github_nodejs_http_parser():
actual = "@com_github_nodejs_http_parser//:http_parser",
)

def _com_github_nodejs_llhttp():
_repository_impl(
name = "com_github_nodejs_llhttp",
build_file = "@envoy//bazel/external:llhttp.BUILD",
)
native.bind(
name = "llhttp",
actual = "@com_github_nodejs_llhttp//:llhttp",
)

def _com_google_googletest():
_repository_impl("com_google_googletest")
native.bind(
Expand Down
7 changes: 7 additions & 0 deletions bazel/repository_locations.bzl
Expand Up @@ -290,6 +290,13 @@ DEPENDENCY_REPOSITORIES = dict(
use_category = ["dataplane"],
cpe = "N/A",
),
com_github_nodejs_llhttp = dict(
sha256 = "48f882f0b6cecc48aec8f81072ee4d80fe9a4b5e1bce009e3cf8aecbe5892c1a",
strip_prefix = "llhttp-release-v2.0.5",
urls = ["https://github.com/nodejs/llhttp/archive/release/v2.0.5.tar.gz"],
use_category = ["dataplane"],
cpe = "N/A",
),
com_github_pallets_jinja = dict(
sha256 = "db49236731373e4f3118af880eb91bb0aa6978bc0cf8b35760f6a026f1a9ffc4",
strip_prefix = "jinja-2.10.3",
Expand Down
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Expand Up @@ -24,6 +24,7 @@ Changes
Can be reverted temporarily by setting runtime feature `envoy.reloadable_features.fix_upgrade_response` to false.
* http: remove legacy connection pool code and their runtime features: `envoy.reloadable_features.new_http1_connection_pool_behavior` and
`envoy.reloadable_features.new_http2_connection_pool_behavior`.
* http: add llhttp as an alternative http parser
* listener: added in place filter chain update flow for tcp listener update which doesn't close connections if the corresponding network filter chain is equivalent during the listener update.
Can be disabled by setting runtime feature `envoy.reloadable_features.listener_in_place_filterchain_update` to false.
Also added additional draining filter chain stat for :ref:`listener manager <config_listener_manager_stats>` to track the number of draining filter chains and the number of in place update attempts.
Expand Down
5 changes: 5 additions & 0 deletions include/envoy/server/options.h
Expand Up @@ -195,6 +195,11 @@ class Options {
*/
virtual bool fakeSymbolTableEnabled() const PURE;

/**
* @return whether to use the legacy HTTP/1.x parser.
*/
virtual bool legacyHttpParserEnabled() const PURE;

/**
* @return bool indicating whether cpuset size should determine the number of worker threads.
*/
Expand Down
45 changes: 44 additions & 1 deletion source/common/http/http1/BUILD
Expand Up @@ -18,8 +18,9 @@ envoy_cc_library(
name = "codec_lib",
srcs = ["codec_impl.cc"],
hdrs = ["codec_impl.h"],
external_deps = ["http_parser"],
deps = [
":parser_factory_lib",
":parser_interface",
"//include/envoy/buffer:buffer_interface",
"//include/envoy/http:codec_interface",
"//include/envoy/http:header_map_interface",
Expand Down Expand Up @@ -66,3 +67,45 @@ envoy_cc_library(
"//source/common/upstream:upstream_lib",
],
)

envoy_cc_library(
name = "parser_interface",
hdrs = ["parser.h"],
)

envoy_cc_library(
name = "llhttp_lib",
srcs = ["llhttp_parser.cc"],
hdrs = ["llhttp_parser.h"],
external_deps = [
"llhttp",
],
deps = [
":parser_interface",
"//source/common/common:assert_lib",
],
)

envoy_cc_library(
name = "legacy_http_parser_lib",
srcs = ["legacy_http_parser.cc"],
hdrs = ["legacy_http_parser.h"],
external_deps = [
"http_parser",
],
deps = [
":parser_interface",
"//source/common/common:assert_lib",
],
)

envoy_cc_library(
name = "parser_factory_lib",
srcs = ["parser_factory.cc"],
hdrs = ["parser_factory.h"],
deps = [
":legacy_http_parser_lib",
":llhttp_lib",
":parser_interface",
],
)