Skip to content

Commit

Permalink
mobile: Remove #ifdef ENVOY_ENABLE_QUIC (envoyproxy#35774)
Browse files Browse the repository at this point in the history
This PR enables Envoy Mobile to always have HTTP/3 support.

Risk Level: low
Testing: CI
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: mobile

Signed-off-by: Fredy Wijaya <[email protected]>
  • Loading branch information
fredyw authored Aug 21, 2024
1 parent 1e3a53c commit ec09f36
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 60 deletions.
9 changes: 2 additions & 7 deletions mobile/envoy_build_config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ load(
"@envoy//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_mobile_package",
"envoy_select_enable_http3",
"envoy_select_envoy_mobile_listener",
)

Expand All @@ -21,6 +20,7 @@ envoy_cc_library(
"extension_registry_platform_additions",
"@envoy//source/common/http/matching:inputs_lib",
"@envoy//source/common/network:socket_lib",
"@envoy//source/common/quic:quic_transport_socket_factory_lib",
"@envoy//source/common/router:upstream_codec_filter_lib",
"@envoy//source/common/tls/cert_validator:cert_validator_lib",
"@envoy//source/common/upstream:default_local_address_selector_factory",
Expand Down Expand Up @@ -52,12 +52,7 @@ envoy_cc_library(
"@envoy_mobile//library/common/extensions/key_value/platform:config",
"@envoy_mobile//library/common/extensions/listener_managers/api_listener_manager:api_listener_manager_lib",
"@envoy_mobile//library/common/extensions/retry/options/network_configuration:config",
] + envoy_select_enable_http3(
[
"@envoy//source/common/quic:quic_transport_socket_factory_lib",
],
"@envoy",
) + envoy_select_envoy_mobile_listener(
] + envoy_select_envoy_mobile_listener(
[
"@envoy//source/extensions/udp_packet_writer/default:config",
"@envoy//source/common/listener_manager:listener_manager_lib",
Expand Down
8 changes: 2 additions & 6 deletions mobile/envoy_build_config/extension_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@
#include "source/common/listener_manager/connection_handler_impl.h"
#endif

#ifdef ENVOY_ENABLE_QUIC
#ifdef ENVOY_MOBILE_ENABLE_LISTENER
#include "source/common/quic/server_codec_impl.h"
#include "source/extensions/quic/connection_id_generator/envoy_deterministic_connection_id_generator_config.h"
#include "source/extensions/quic/crypto_stream/envoy_quic_crypto_server_stream.h"
#include "source/extensions/quic/proof_source/envoy_quic_proof_source_factory_impl.h"
#include "source/extensions/udp_packet_writer/default/config.h"
#endif
#include "source/common/quic/quic_client_transport_socket_factory.h"
#endif

#include "source/common/quic/quic_client_transport_socket_factory.h"
#include "extension_registry_platform_additions.h"
#include "library/common/extensions/cert_validator/platform_bridge/config.h"
#include "library/common/extensions/filters/http/local_error/config.h"
Expand Down Expand Up @@ -182,8 +180,6 @@ void ExtensionRegistry::registerFactories() {
Server::FilterChain::forceRegisterFilterChainNameActionFactory();
#endif

#ifdef ENVOY_ENABLE_QUIC

#ifdef ENVOY_MOBILE_ENABLE_LISTENER
// These are QUIC downstream factories required if Envoy Mobile is compiled with
// proxy functionality and QUIC support.
Expand All @@ -195,8 +191,8 @@ void ExtensionRegistry::registerFactories() {
Quic::forceRegisterEnvoyQuicProofSourceFactoryImpl();
Quic::forceRegisterEnvoyDeterministicConnectionIdGeneratorConfigFactory();
#endif

Quic::forceRegisterQuicClientTransportSocketConfigFactory();
#endif
}

} // namespace Envoy
14 changes: 1 addition & 13 deletions mobile/library/cc/engine_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
namespace Envoy {
namespace Platform {

EngineBuilder::EngineBuilder() : callbacks_(std::make_unique<EngineCallbacks>()) {
#ifndef ENVOY_ENABLE_QUIC
enable_http3_ = false;
#endif
}
EngineBuilder::EngineBuilder() : callbacks_(std::make_unique<EngineCallbacks>()) {}

EngineBuilder& EngineBuilder::setNetworkThreadPriority(int thread_priority) {
network_thread_priority_ = thread_priority;
Expand All @@ -61,7 +57,6 @@ EngineBuilder& EngineBuilder::setUseCares(bool use_cares) {
return *this;
}
#endif

EngineBuilder& EngineBuilder::setLogLevel(Logger::Logger::Levels log_level) {
log_level_ = log_level;
return *this;
Expand Down Expand Up @@ -192,7 +187,6 @@ EngineBuilder& EngineBuilder::enableSocketTagging(bool socket_tagging_on) {
return *this;
}

#ifdef ENVOY_ENABLE_QUIC
EngineBuilder& EngineBuilder::enableHttp3(bool http3_on) {
enable_http3_ = http3_on;
return *this;
Expand Down Expand Up @@ -223,8 +217,6 @@ EngineBuilder& EngineBuilder::enablePortMigration(bool enable_port_migration) {
return *this;
}

#endif

EngineBuilder& EngineBuilder::setForceAlwaysUsev6(bool value) {
always_use_v6_ = value;
return *this;
Expand Down Expand Up @@ -382,14 +374,10 @@ std::unique_ptr<envoy::config::bootstrap::v3::Bootstrap> EngineBuilder::generate

// Set up the optional filters
if (enable_http3_) {
#ifdef ENVOY_ENABLE_QUIC
envoy::extensions::filters::http::alternate_protocols_cache::v3::FilterConfig cache_config;
auto* cache_filter = hcm->add_http_filters();
cache_filter->set_name("alternate_protocols_cache");
cache_filter->mutable_typed_config()->PackFrom(cache_config);
#else
throw std::runtime_error("http3 functionality was not compiled in this build of Envoy Mobile");
#endif
}

if (gzip_decompression_filter_) {
Expand Down
2 changes: 0 additions & 2 deletions mobile/library/cc/engine_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ class EngineBuilder {
EngineBuilder& enableGzipDecompression(bool gzip_decompression_on);
EngineBuilder& enableBrotliDecompression(bool brotli_decompression_on);
EngineBuilder& enableSocketTagging(bool socket_tagging_on);
#ifdef ENVOY_ENABLE_QUIC
EngineBuilder& enableHttp3(bool http3_on);
EngineBuilder& setHttp3ConnectionOptions(std::string options);
EngineBuilder& setHttp3ClientConnectionOptions(std::string options);
EngineBuilder& addQuicHint(std::string host, int port);
EngineBuilder& addQuicCanonicalSuffix(std::string suffix);
EngineBuilder& enablePortMigration(bool enable_port_migration);
#endif
EngineBuilder& enableInterfaceBinding(bool interface_binding_on);
EngineBuilder& enableDrainPostDnsRefresh(bool drain_post_dns_refresh_on);
// Sets whether to use GRO for upstream UDP sockets (QUIC/HTTP3).
Expand Down
3 changes: 0 additions & 3 deletions mobile/library/jni/jni_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,6 @@ void configureBuilder(Envoy::JNI::JniHelper& jni_helper, jlong connect_timeout_s
builder.enableGzipDecompression(enable_gzip_decompression == JNI_TRUE);
builder.enableBrotliDecompression(enable_brotli_decompression == JNI_TRUE);
builder.enableSocketTagging(enable_socket_tagging == JNI_TRUE);
#ifdef ENVOY_ENABLE_QUIC
builder.enableHttp3(enable_http3 == JNI_TRUE);
builder.setHttp3ConnectionOptions(
Envoy::JNI::javaStringToCppString(jni_helper, http3_connection_options));
Expand All @@ -1245,8 +1244,6 @@ void configureBuilder(Envoy::JNI::JniHelper& jni_helper, jlong connect_timeout_s
builder.addQuicCanonicalSuffix(suffix);
}
builder.enablePortMigration(enable_port_migration);

#endif
builder.setUseCares(use_cares == JNI_TRUE);
builder.setUseGroIfAvailable(use_gro == JNI_TRUE);
builder.enableInterfaceBinding(enable_interface_binding == JNI_TRUE);
Expand Down
2 changes: 0 additions & 2 deletions mobile/library/objective-c/EnvoyConfiguration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,13 @@ - (instancetype)initWithConnectTimeoutSeconds:(UInt32)connectTimeoutSeconds
builder.addPlatformFilter([filterFactory.filterName toCXXString]);
}

#ifdef ENVOY_ENABLE_QUIC
builder.enableHttp3(self.enableHttp3);
for (NSString *host in self.quicHints) {
builder.addQuicHint([host toCXXString], [[self.quicHints objectForKey:host] intValue]);
}
for (NSString *suffix in self.quicCanonicalSuffixes) {
builder.addQuicCanonicalSuffix([suffix toCXXString]);
}
#endif

builder.enableGzipDecompression(self.enableGzipDecompression);
builder.enableBrotliDecompression(self.enableBrotliDecompression);
Expand Down
7 changes: 0 additions & 7 deletions mobile/library/swift/EngineBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Foundation
/// Builder used for creating and running a new Engine instance.
@objcMembers
open class EngineBuilder: NSObject {
// swiftlint:disable:previous type_body_length
private var engineType: EnvoyEngine.Type = EnvoyEngineImpl.self
private var logLevel: LogLevel = .info
private var connectTimeoutSeconds: UInt32 = 30
Expand All @@ -18,11 +17,7 @@ open class EngineBuilder: NSObject {
private var dnsCacheSaveIntervalSeconds: UInt32 = 1
private var enableGzipDecompression: Bool = true
private var enableBrotliDecompression: Bool = false
#if ENVOY_ENABLE_QUIC
private var enableHttp3: Bool = true
#else
private var enableHttp3: Bool = false
#endif
private var quicHints: [String: Int] = [:]
private var quicCanonicalSuffixes: [String] = []
private var enableInterfaceBinding: Bool = false
Expand Down Expand Up @@ -174,7 +169,6 @@ open class EngineBuilder: NSObject {
return self
}

#if ENVOY_ENABLE_QUIC
/// Specify whether to enable support for HTTP/3 or not. Defaults to true.
///
/// - parameter enableHttp3: whether or not to enable HTTP/3.
Expand Down Expand Up @@ -208,7 +202,6 @@ open class EngineBuilder: NSObject {
self.quicCanonicalSuffixes.append(suffix)
return self
}
#endif

/// Specify whether sockets may attempt to bind to a specific interface, based on network
/// conditions.
Expand Down
21 changes: 1 addition & 20 deletions mobile/test/cc/unit/envoy_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,13 @@ bool socketAddressesEqual(

TEST(TestConfig, ConfigIsApplied) {
EngineBuilder engine_builder;
engine_builder
#ifdef ENVOY_ENABLE_QUIC
.setHttp3ConnectionOptions("5RTO")
engine_builder.setHttp3ConnectionOptions("5RTO")
.setHttp3ClientConnectionOptions("MPQC")
.addQuicHint("www.abc.com", 443)
.addQuicHint("www.def.com", 443)
.addQuicCanonicalSuffix(".opq.com")
.addQuicCanonicalSuffix(".xyz.com")
.enablePortMigration(true)
#endif
.addConnectTimeoutSeconds(123)
.addDnsRefreshSeconds(456)
.addDnsMinRefreshSeconds(567)
Expand Down Expand Up @@ -101,7 +98,6 @@ TEST(TestConfig, ConfigIsApplied) {
"dns_failure_refresh_rate { base_interval { seconds: 789 } max_interval { seconds: 987 } }",
"connection_idle_interval { nanos: 222000000 }",
"connection_keepalive { timeout { seconds: 333 }",
#ifdef ENVOY_ENABLE_QUIC
"connection_options: \"5RTO\"",
"client_connection_options: \"MPQC\"",
"hostname: \"www.abc.com\"",
Expand All @@ -110,7 +106,6 @@ TEST(TestConfig, ConfigIsApplied) {
"canonical_suffixes: \".xyz.com\"",
"num_timeouts_to_trigger_port_migration { value: 4 }",
"idle_network_timeout { seconds: 30 }",
#endif
"key: \"dns_persistent_cache\" save_interval { seconds: 101 }",
"key: \"always_use_v6\" value { bool_value: true }",
"key: \"prefer_quic_client_udp_gro\" value { bool_value: true }",
Expand Down Expand Up @@ -191,13 +186,11 @@ TEST(TestConfig, SetSocketTag) {
EXPECT_THAT(bootstrap->DebugString(), HasSubstr("http.socket_tag.SocketTag"));
}

#ifdef ENVOY_ENABLE_QUIC
TEST(TestConfig, SetAltSvcCache) {
EngineBuilder engine_builder;
std::unique_ptr<Bootstrap> bootstrap = engine_builder.generateBootstrap();
EXPECT_THAT(bootstrap->DebugString(), HasSubstr("alternate_protocols_cache"));
}
#endif

TEST(TestConfig, StreamIdleTimeout) {
EngineBuilder engine_builder;
Expand Down Expand Up @@ -311,26 +304,15 @@ TEST(TestConfig, DisableHttp3) {
EngineBuilder engine_builder;

std::unique_ptr<Bootstrap> bootstrap = engine_builder.generateBootstrap();
#ifdef ENVOY_ENABLE_QUIC
EXPECT_THAT(bootstrap->ShortDebugString(),
HasSubstr("envoy.extensions.filters.http.alternate_protocols_cache.v3.FilterConfig"));
#endif
#ifndef ENVOY_ENABLE_QUIC
EXPECT_THAT(
bootstrap->ShortDebugString(),
Not(HasSubstr("envoy.extensions.filters.http.alternate_protocols_cache.v3.FilterConfig")));
#endif

#ifdef ENVOY_ENABLE_QUIC
engine_builder.enableHttp3(false);
bootstrap = engine_builder.generateBootstrap();
EXPECT_THAT(
bootstrap->ShortDebugString(),
Not(HasSubstr("envoy.extensions.filters.http.alternate_protocols_cache.v3.FilterConfig")));
#endif
}

#ifdef ENVOY_ENABLE_QUIC
TEST(TestConfig, UdpSocketReceiveBufferSize) {
EngineBuilder engine_builder;
engine_builder.enableHttp3(true);
Expand Down Expand Up @@ -392,7 +374,6 @@ TEST(TestConfig, UdpSocketSendBufferSize) {
EXPECT_TRUE(snd_buf_option->type().has_datagram());
EXPECT_EQ(snd_buf_option->int_value(), 1452 * 20);
}
#endif

TEST(TestConfig, EnablePlatformCertificatesValidation) {
EngineBuilder engine_builder;
Expand Down

0 comments on commit ec09f36

Please sign in to comment.