Skip to content

Commit

Permalink
Add Bumping filter
Browse files Browse the repository at this point in the history
Signed-off-by: leizhang <[email protected]>
  • Loading branch information
liverbirdkte committed Sep 11, 2022
1 parent 6660562 commit 47fc83b
Show file tree
Hide file tree
Showing 13 changed files with 725 additions and 2 deletions.
12 changes: 12 additions & 0 deletions api/envoy/extensions/filters/network/bumping/v3/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/config/accesslog/v3:pkg",
"@com_github_cncf_udpa//udpa/annotations:pkg",
],
)
37 changes: 37 additions & 0 deletions api/envoy/extensions/filters/network/bumping/v3/bumping.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
syntax = "proto3";

package envoy.extensions.filters.network.bumping.v3;

import "envoy/config/accesslog/v3/accesslog.proto";

import "google/protobuf/wrappers.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.network.bumping.v3";
option java_outer_classname = "BumpingProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/bumping/v3;bumpingv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Bumping]
// Bumping :ref:`configuration overview <config_network_filters_bumping>`.
// [#extension: envoy.filters.network.bumping]

message Bumping {
// The prefix to use when emitting :ref:`statistics
// <config_network_filters_bumping_stats>`.
string stat_prefix = 1 [(validate.rules).string = {min_len: 1}];

// The upstream cluster to connect to.
string cluster = 2;

// Configuration for :ref:`access logs <arch_overview_access_logs>`
// emitted by the this bumping filter.
repeated config.accesslog.v3.AccessLog access_log = 3;

// The maximum number of unsuccessful connection attempts that will be made before
// giving up. If the parameter is not specified, 1 connection attempt will be made.
google.protobuf.UInt32Value max_connect_attempts = 4 [(validate.rules).uint32 = {gte: 1}];
}
1 change: 1 addition & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ proto_library(
"//envoy/extensions/filters/listener/original_src/v3:pkg",
"//envoy/extensions/filters/listener/proxy_protocol/v3:pkg",
"//envoy/extensions/filters/listener/tls_inspector/v3:pkg",
"//envoy/extensions/filters/network/bumping/v3:pkg",
"//envoy/extensions/filters/network/connection_limit/v3:pkg",
"//envoy/extensions/filters/network/direct_response/v3:pkg",
"//envoy/extensions/filters/network/dubbo_proxy/router/v3:pkg",
Expand Down
2 changes: 2 additions & 0 deletions envoy/network/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ class Connection : public Event::DeferredDeletable,
* return value is cwnd(in packets) times the connection's MSS.
*/
virtual absl::optional<uint64_t> congestionWindowInBytes() const PURE;

bool write_disable{false};
};

using ConnectionPtr = std::unique_ptr<Connection>;
Expand Down
4 changes: 3 additions & 1 deletion source/common/network/connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ void ConnectionImpl::onFileEvent(uint32_t events) {
}

if (events & Event::FileReadyType::Write) {
onWriteReady();
if (!write_disable) {
onWriteReady();
}
}

// It's possible for a write event callback to close the socket (which will cause fd_ to be -1).
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/extensions_build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ EXTENSIONS = {
"envoy.filters.network.sni_dynamic_forward_proxy": "//source/extensions/filters/network/sni_dynamic_forward_proxy:config",
"envoy.filters.network.wasm": "//source/extensions/filters/network/wasm:config",
"envoy.filters.network.zookeeper_proxy": "//source/extensions/filters/network/zookeeper_proxy:config",

"envoy.filters.network.bumping": "//source/extensions/filters/network/bumping:config",
#
# UDP filters
#
Expand Down
7 changes: 7 additions & 0 deletions source/extensions/extensions_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ envoy.filters.network.zookeeper_proxy:
status: alpha
type_urls:
- envoy.extensions.filters.network.zookeeper_proxy.v3.ZooKeeperProxy
envoy.filters.network.bumping:
categories:
- envoy.filters.network
security_posture: unknown
status: alpha
type_urls:
- envoy.extensions.filters.network.bumping.v3.Bumping
envoy.filters.thrift.header_to_metadata:
categories:
- envoy.thrift_proxy.filters
Expand Down
76 changes: 76 additions & 0 deletions source/extensions/filters/network/bumping/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_extension",
"envoy_cc_library",
"envoy_extension_package",
)

licenses(["notice"]) # Apache 2

envoy_extension_package()

envoy_cc_library(
name = "bumping_lib",
srcs = [
"bumping.cc",
],
hdrs = [
"bumping.h",
],
external_deps = [
"ssl",
],
deps = [
"//envoy/access_log:access_log_interface",
"//envoy/buffer:buffer_interface",
"//envoy/common:time_interface",
"//envoy/event:dispatcher_interface",
"//envoy/network:connection_interface",
"//envoy/network:filter_interface",
"//envoy/router:router_interface",
"//envoy/server:filter_config_interface",
"//envoy/stats:stats_interface",
"//envoy/stats:stats_macros",
"//envoy/stats:timespan_interface",
"//envoy/stream_info:filter_state_interface",
"//envoy/tcp:conn_pool_interface",
"//envoy/tcp:upstream_interface",
"//envoy/upstream:cluster_manager_interface",
"//envoy/upstream:upstream_interface",
"//source/common/access_log:access_log_lib",
"//source/common/common:assert_lib",
"//source/common/common:empty_string",
"//source/common/common:macros",
"//source/common/common:minimal_logger_lib",
"//source/common/http:codec_client_lib",
"//source/common/network:application_protocol_lib",
"//source/common/network:cidr_range_lib",
"//source/common/network:filter_lib",
"//source/common/network:proxy_protocol_filter_state_lib",
"//source/common/network:socket_option_factory_lib",
"//source/common/network:transport_socket_options_lib",
"//source/common/network:upstream_server_name_lib",
"//source/common/network:upstream_socket_options_filter_state_lib",
"//source/common/network:utility_lib",
"//source/common/stream_info:stream_info_lib",
"//source/common/upstream:load_balancer_lib",
"//source/extensions/filters/network:well_known_names",
"//source/extensions/upstreams/tcp/generic:config",
"@envoy_api//envoy/config/accesslog/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/bumping/v3:pkg_cc_proto",
],
)

envoy_cc_extension(
name = "config",
srcs = ["config.cc"],
hdrs = ["config.h"],
deps = [
":bumping_lib",
"//envoy/registry",
"//source/common/tcp_proxy",
"//source/extensions/filters/network:well_known_names",
"//source/extensions/filters/network/common:factory_base_lib",
"@envoy_api//envoy/extensions/filters/network/bumping/v3:pkg_cc_proto",
],
)
Loading

0 comments on commit 47fc83b

Please sign in to comment.