aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <y-zeng@users.noreply.github.com>2017-04-04 21:33:24 -0700
committerGravatar GitHub <noreply@github.com>2017-04-04 21:33:24 -0700
commit526e624c58201a754b5643b2f77c4879d313a523 (patch)
tree87d8c84015211dd104a40d1d4571fb7f728791b1
parent500e361826cb52a6d8db6839dc209dcf3266df0f (diff)
parentb0c2225336d1a71ebb32f850cbec968ef9c96820 (diff)
Merge pull request #9902 from y-zeng/keepalive_server
Client-side keepalive pings server enforcement
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile2
-rw-r--r--include/grpc/impl/codegen/grpc_types.h22
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.c184
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.c22
-rw-r--r--src/core/ext/transport/chttp2/transport/internal.h18
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.c20
-rw-r--r--test/core/end2end/end2end_nosec_tests.c8
-rw-r--r--test/core/end2end/end2end_tests.c8
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py1
-rwxr-xr-xtest/core/end2end/generate_tests.bzl1
-rw-r--r--test/core/end2end/tests/bad_ping.c237
-rw-r--r--test/core/end2end/tests/keepalive_timeout.c6
-rw-r--r--test/core/end2end/tests/ping.c26
-rw-r--r--tools/run_tests/generated/sources_and_headers.json2
-rw-r--r--tools/run_tests/generated/tests.json454
-rw-r--r--vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj2
-rw-r--r--vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters3
-rw-r--r--vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj2
-rw-r--r--vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters3
20 files changed, 966 insertions, 57 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 332f8a541c..acf47e5bfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4386,6 +4386,7 @@ add_library(end2end_tests
test/core/end2end/end2end_test_utils.c
test/core/end2end/tests/authority_not_supported.c
test/core/end2end/tests/bad_hostname.c
+ test/core/end2end/tests/bad_ping.c
test/core/end2end/tests/binary_metadata.c
test/core/end2end/tests/call_creds.c
test/core/end2end/tests/cancel_after_accept.c
@@ -4483,6 +4484,7 @@ add_library(end2end_nosec_tests
test/core/end2end/end2end_test_utils.c
test/core/end2end/tests/authority_not_supported.c
test/core/end2end/tests/bad_hostname.c
+ test/core/end2end/tests/bad_ping.c
test/core/end2end/tests/binary_metadata.c
test/core/end2end/tests/cancel_after_accept.c
test/core/end2end/tests/cancel_after_client_done.c
diff --git a/Makefile b/Makefile
index 8bad909fe9..5ad05570f9 100644
--- a/Makefile
+++ b/Makefile
@@ -8221,6 +8221,7 @@ LIBEND2END_TESTS_SRC = \
test/core/end2end/end2end_test_utils.c \
test/core/end2end/tests/authority_not_supported.c \
test/core/end2end/tests/bad_hostname.c \
+ test/core/end2end/tests/bad_ping.c \
test/core/end2end/tests/binary_metadata.c \
test/core/end2end/tests/call_creds.c \
test/core/end2end/tests/cancel_after_accept.c \
@@ -8313,6 +8314,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \
test/core/end2end/end2end_test_utils.c \
test/core/end2end/tests/authority_not_supported.c \
test/core/end2end/tests/bad_hostname.c \
+ test/core/end2end/tests/bad_ping.c \
test/core/end2end/tests/binary_metadata.c \
test/core/end2end/tests/cancel_after_accept.c \
test/core/end2end/tests/cancel_after_client_done.c \
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index 5beac83a3b..8a8b20650f 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -205,15 +205,25 @@ typedef struct {
a data frame or header frame) */
#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
"grpc.http2.max_pings_without_data"
+/** How many misbehaving pings the server can bear before sending goaway and
+ closing the transport?
+ (0 indicates that the server can bear an infinite number of misbehaving
+ pings) */
+#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes"
+/** Minimum allowed time between two pings without sending any data frame. Int
+ valued, seconds */
+#define GRPC_ARG_HTTP2_MIN_PING_INTERVAL_WITHOUT_DATA_MS \
+ "grpc.http2.min_ping_interval_without_data_ms"
/** How much data are we willing to queue up per stream if
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
-/** After a duration of this time the client pings the server to see if the
- transport is still alive. Int valued, seconds. */
-#define GRPC_ARG_CLIENT_KEEPALIVE_TIME_S "grpc.client_keepalive_time"
-/** After waiting for a duration of this time, if the client does not receive
- the ping ack, it will close the transport. Int valued, seconds. */
-#define GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S "grpc.client_keepalive_timeout"
+/** After a duration of this time the client/server pings its peer to see if the
+ transport is still alive. Int valued, milliseconds. */
+#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms"
+/** After waiting for a duration of this time, if the keepalive ping sender does
+ not receive the ping ack, it will close the transport. Int valued,
+ milliseconds. */
+#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms"
/** Is it permissible to send keepalive pings without any outstanding streams.
Int valued, 0(false)/1(true). */
#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
index a8e320d037..e2816b0e04 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
@@ -69,13 +69,21 @@
#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
#define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024)
-#define DEFAULT_CLIENT_KEEPALIVE_TIME_S INT_MAX
-#define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_S 20
+#define DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX
+#define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */
+#define DEFAULT_SERVER_KEEPALIVE_TIME_MS 7200000 /* 2 hours */
+#define DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */
#define DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false
-
-static int g_default_client_keepalive_time_s = DEFAULT_CLIENT_KEEPALIVE_TIME_S;
-static int g_default_client_keepalive_timeout_s =
- DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_S;
+#define KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2
+
+static int g_default_client_keepalive_time_ms =
+ DEFAULT_CLIENT_KEEPALIVE_TIME_MS;
+static int g_default_client_keepalive_timeout_ms =
+ DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS;
+static int g_default_server_keepalive_time_ms =
+ DEFAULT_SERVER_KEEPALIVE_TIME_MS;
+static int g_default_server_keepalive_timeout_ms =
+ DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS;
static bool g_default_keepalive_permit_without_calls =
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS;
@@ -153,6 +161,8 @@ static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 0
#define DEFAULT_MAX_PINGS_BETWEEN_DATA 3
+#define DEFAULT_MAX_PING_STRIKES 2
+#define DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */
/** keepalive-relevant functions */
static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
@@ -351,19 +361,35 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
.max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA,
.min_time_between_pings =
gpr_time_from_millis(DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, GPR_TIMESPAN),
+ .max_ping_strikes = DEFAULT_MAX_PING_STRIKES,
+ .min_ping_interval_without_data = gpr_time_from_millis(
+ DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, GPR_TIMESPAN),
};
- /* client-side keepalive setting */
- t->keepalive_time =
- g_default_client_keepalive_time_s == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_seconds(g_default_client_keepalive_time_s,
- GPR_TIMESPAN);
- t->keepalive_timeout =
- g_default_client_keepalive_timeout_s == INT_MAX
- ? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_seconds(g_default_client_keepalive_timeout_s,
- GPR_TIMESPAN);
+ /* Keepalive setting */
+ if (t->is_client) {
+ t->keepalive_time =
+ g_default_client_keepalive_time_ms == INT_MAX
+ ? gpr_inf_future(GPR_TIMESPAN)
+ : gpr_time_from_millis(g_default_client_keepalive_time_ms,
+ GPR_TIMESPAN);
+ t->keepalive_timeout =
+ g_default_client_keepalive_timeout_ms == INT_MAX
+ ? gpr_inf_future(GPR_TIMESPAN)
+ : gpr_time_from_millis(g_default_client_keepalive_timeout_ms,
+ GPR_TIMESPAN);
+ } else {
+ t->keepalive_time =
+ g_default_server_keepalive_time_ms == INT_MAX
+ ? gpr_inf_future(GPR_TIMESPAN)
+ : gpr_time_from_millis(g_default_server_keepalive_time_ms,
+ GPR_TIMESPAN);
+ t->keepalive_timeout =
+ g_default_server_keepalive_timeout_ms == INT_MAX
+ ? gpr_inf_future(GPR_TIMESPAN)
+ : gpr_time_from_millis(g_default_server_keepalive_timeout_ms,
+ GPR_TIMESPAN);
+ }
t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls;
if (channel_args) {
@@ -397,6 +423,11 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
&channel_args->args[i],
(grpc_integer_options){DEFAULT_MAX_PINGS_BETWEEN_DATA, 0, INT_MAX});
} else if (0 == strcmp(channel_args->args[i].key,
+ GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
+ t->ping_policy.max_ping_strikes = grpc_channel_arg_get_integer(
+ &channel_args->args[i],
+ (grpc_integer_options){DEFAULT_MAX_PING_STRIKES, 0, INT_MAX});
+ } else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS)) {
t->ping_policy.min_time_between_pings = gpr_time_from_millis(
grpc_channel_arg_get_integer(
@@ -404,6 +435,15 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
(grpc_integer_options){DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, 0,
INT_MAX}),
GPR_TIMESPAN);
+ } else if (0 ==
+ strcmp(channel_args->args[i].key,
+ GRPC_ARG_HTTP2_MIN_PING_INTERVAL_WITHOUT_DATA_MS)) {
+ t->ping_policy.min_ping_interval_without_data = gpr_time_from_millis(
+ grpc_channel_arg_get_integer(
+ &channel_args->args[i],
+ (grpc_integer_options){
+ DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, 0, INT_MAX}),
+ GPR_TIMESPAN);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
@@ -414,23 +454,27 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->enable_bdp_probe = grpc_channel_arg_get_integer(
&channel_args->args[i], (grpc_integer_options){1, 0, 1});
} else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_CLIENT_KEEPALIVE_TIME_S)) {
+ GRPC_ARG_KEEPALIVE_TIME_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
- (grpc_integer_options){g_default_client_keepalive_time_s, 1,
- INT_MAX});
+ (grpc_integer_options){t->is_client
+ ? g_default_client_keepalive_time_ms
+ : g_default_server_keepalive_time_ms,
+ 1, INT_MAX});
t->keepalive_time = value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_seconds(value, GPR_TIMESPAN);
+ : gpr_time_from_millis(value, GPR_TIMESPAN);
} else if (0 == strcmp(channel_args->args[i].key,
- GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S)) {
+ GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
- (grpc_integer_options){g_default_client_keepalive_timeout_s, 0,
- INT_MAX});
+ (grpc_integer_options){t->is_client
+ ? g_default_client_keepalive_timeout_ms
+ : g_default_server_keepalive_timeout_ms,
+ 0, INT_MAX});
t->keepalive_timeout = value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
- : gpr_time_from_seconds(value, GPR_TIMESPAN);
+ : gpr_time_from_millis(value, GPR_TIMESPAN);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
t->keepalive_permit_without_calls =
@@ -488,8 +532,11 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->ping_policy.max_pings_without_data;
t->ping_state.is_delayed_ping_timer_set = false;
- /** Start client-side keepalive pings */
- if (t->is_client) {
+ t->ping_recv_state.last_ping_recv_time = gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.ping_strikes = 0;
+
+ /* Start keepalive pings */
+ if (gpr_time_cmp(t->keepalive_time, gpr_inf_future(GPR_TIMESPAN)) != 0) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
grpc_timer_init(
@@ -918,6 +965,26 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
// GRPC_CHTTP2_IF_TRACING(
// gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg));
t->seen_goaway = 1;
+
+ /* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
+ * data equal to “too_many_pings”, it should log the occurrence at a log level
+ * that is enabled by default and double the configured KEEPALIVE_TIME used
+ * for new connections on that channel. */
+ if (t->is_client && goaway_error == GRPC_HTTP2_ENHANCE_YOUR_CALM &&
+ grpc_slice_str_cmp(goaway_text, "too_many_pings") == 0) {
+ gpr_log(GPR_ERROR,
+ "Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
+ "data equal to \"too_many_pings\"");
+ double current_keepalive_time_ms =
+ gpr_timespec_to_micros(t->keepalive_time) / 1000;
+ t->keepalive_time =
+ current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER
+ ? gpr_inf_future(GPR_TIMESPAN)
+ : gpr_time_from_millis((int64_t)(current_keepalive_time_ms *
+ KEEPALIVE_TIME_BACKOFF_MULTIPLIER),
+ GPR_TIMESPAN);
+ }
+
/* lie: use transient failure from the transport to indicate goaway has been
* received */
connectivity_state_set(
@@ -1459,6 +1526,21 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
+void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
+ grpc_chttp2_transport *t) {
+ gpr_log(GPR_DEBUG, "PING strike");
+ if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
+ t->ping_policy.max_ping_strikes != 0) {
+ send_goaway(exec_ctx, t,
+ grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
+ GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
+ /*The transport will be closed after the write is done */
+ close_transport_locked(
+ exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"));
+ }
+}
+
static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
void *stream_op,
grpc_error *error_ignored) {
@@ -2125,6 +2207,10 @@ static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
if (grpc_http_trace) {
gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string);
}
+ /* Reset the keepalive ping timer */
+ if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
+ grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
+ }
grpc_bdp_estimator_start_ping(&t->bdp_estimator);
}
@@ -2139,20 +2225,32 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
}
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args) {
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+ bool is_client) {
size_t i;
if (args) {
for (i = 0; i < args->num_args; i++) {
- if (0 == strcmp(args->args[i].key, GRPC_ARG_CLIENT_KEEPALIVE_TIME_S)) {
- g_default_client_keepalive_time_s = grpc_channel_arg_get_integer(
- &args->args[i], (grpc_integer_options){
- g_default_client_keepalive_time_s, 1, INT_MAX});
- } else if (0 == strcmp(args->args[i].key,
- GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S)) {
- g_default_client_keepalive_timeout_s = grpc_channel_arg_get_integer(
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
+ const int value = grpc_channel_arg_get_integer(
+ &args->args[i],
+ (grpc_integer_options){g_default_client_keepalive_time_ms, 1,
+ INT_MAX});
+ if (is_client) {
+ g_default_client_keepalive_time_ms = value;
+ } else {
+ g_default_server_keepalive_time_ms = value;
+ }
+ } else if (0 ==
+ strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
+ const int value = grpc_channel_arg_get_integer(
&args->args[i],
- (grpc_integer_options){g_default_client_keepalive_timeout_s, 0,
+ (grpc_integer_options){g_default_client_keepalive_timeout_ms, 0,
INT_MAX});
+ if (is_client) {
+ g_default_client_keepalive_timeout_ms = value;
+ } else {
+ g_default_server_keepalive_timeout_ms = value;
+ }
} else if (0 == strcmp(args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
g_default_keepalive_permit_without_calls =
@@ -2170,7 +2268,8 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_chttp2_transport *t = arg;
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
if (error == GRPC_ERROR_NONE && !(t->destroying || t->closed)) {
- if (t->keepalive_permit_without_calls || t->stream_map.count > 0) {
+ if (t->keepalive_permit_without_calls ||
+ grpc_chttp2_stream_map_size(&t->stream_map) > 0) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end");
send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE,
@@ -2183,6 +2282,13 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
&t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
}
+ } else if (error == GRPC_ERROR_CANCELLED && !(t->destroying || t->closed)) {
+ /* The keepalive ping timer may be cancelled by bdp */
+ GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
+ grpc_timer_init(
+ exec_ctx, &t->keepalive_ping_timer,
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time),
+ &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
}
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping");
}
@@ -2224,8 +2330,8 @@ static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
"keepalive watchdog timeout"));
}
} else {
- /** The watchdog timer should have been cancelled by
- finish_keepalive_ping_locked. */
+ /* The watchdog timer should have been cancelled by
+ * finish_keepalive_ping_locked. */
if (error != GRPC_ERROR_CANCELLED) {
gpr_log(GPR_ERROR, "keepalive_ping_end state error: %d (expect: %d)",
t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING);
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c
index 46dafdb62f..6016e43127 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.c
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.c
@@ -103,6 +103,28 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
if (p->is_ack) {
grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes);
} else {
+ if (!t->is_client) {
+ gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ gpr_timespec next_allowed_ping =
+ gpr_time_add(t->ping_recv_state.last_ping_recv_time,
+ t->ping_policy.min_ping_interval_without_data);
+
+ if (t->keepalive_permit_without_calls == 0 &&
+ grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
+ /* According to RFC1122, the interval of TCP Keep-Alive is default to
+ no less than two hours. When there is no outstanding streams, we
+ restrict the number of PINGS equivalent to TCP Keep-Alive. */
+ next_allowed_ping =
+ gpr_time_add(t->ping_recv_state.last_ping_recv_time,
+ gpr_time_from_seconds(7200, GPR_TIMESPAN));
+ }
+
+ if (gpr_time_cmp(next_allowed_ping, now) > 0) {
+ grpc_chttp2_add_ping_strike(exec_ctx, t);
+ }
+
+ t->ping_recv_state.last_ping_recv_time = now;
+ }
if (!g_disable_ping_ack) {
if (t->ping_ack_count == t->ping_ack_capacity) {
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h
index 50993e4ecd..6eb848b8d7 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -97,6 +97,8 @@ typedef struct {
typedef struct {
gpr_timespec min_time_between_pings;
int max_pings_without_data;
+ int max_ping_strikes;
+ gpr_timespec min_ping_interval_without_data;
} grpc_chttp2_repeated_ping_policy;
typedef struct {
@@ -106,6 +108,11 @@ typedef struct {
bool is_delayed_ping_timer_set;
} grpc_chttp2_repeated_ping_state;
+typedef struct {
+ gpr_timespec last_ping_recv_time;
+ int ping_strikes;
+} grpc_chttp2_server_ping_recv_state;
+
/* deframer state for the overall http2 stream of bytes */
typedef enum {
/* prefix: one entry per http2 connection prefix byte */
@@ -316,6 +323,7 @@ struct grpc_chttp2_transport {
size_t ping_ack_count;
size_t ping_ack_capacity;
uint64_t *ping_acks;
+ grpc_chttp2_server_ping_recv_state ping_recv_state;
/** parser for headers */
grpc_chttp2_hpack_parser hpack_parser;
@@ -792,6 +800,13 @@ void grpc_chttp2_incoming_byte_stream_finished(
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
uint64_t id);
+/** Add a new ping strike to ping_recv_state.ping_strikes. If
+ ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY
+ with error code ENHANCE_YOUR_CALM and additional debug data resembling
+ “too_many_pings” followed by immediately closing the connection. */
+void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
+ grpc_chttp2_transport *t);
+
typedef enum {
/* don't initiate a transport write, but piggyback on the next one */
GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK,
@@ -831,6 +846,7 @@ uint32_t grpc_chttp2_target_incoming_window(grpc_chttp2_transport *t);
/** Set the default keepalive configurations, must only be called at
initialization */
-void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args);
+void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
+ bool is_client);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */
diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c
index 0869056f56..be41b3d186 100644
--- a/src/core/ext/transport/chttp2/transport/writing.c
+++ b/src/core/ext/transport/chttp2/transport/writing.c
@@ -229,6 +229,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
now_writing = true;
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
+ if (!t->is_client) {
+ t->ping_recv_state.last_ping_recv_time =
+ gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.ping_strikes = 0;
+ }
}
/* send any window updates */
if (s->announce_window > 0) {
@@ -238,6 +243,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
s->id, s->announce_window, &s->stats.outgoing));
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
+ if (!t->is_client) {
+ t->ping_recv_state.last_ping_recv_time =
+ gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.ping_strikes = 0;
+ }
GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce);
}
if (sent_initial_metadata) {
@@ -270,6 +280,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
send_bytes);
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
+ if (!t->is_client) {
+ t->ping_recv_state.last_ping_recv_time =
+ gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.ping_strikes = 0;
+ }
if (is_last_frame) {
s->send_trailing_metadata = NULL;
s->sent_trailing_metadata = true;
@@ -345,6 +360,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
0, announced, &throwaway_stats));
t->ping_state.pings_before_data_required =
t->ping_policy.max_pings_without_data;
+ if (!t->is_client) {
+ t->ping_recv_state.last_ping_recv_time =
+ gpr_inf_past(GPR_CLOCK_MONOTONIC);
+ t->ping_recv_state.ping_strikes = 0;
+ }
}
for (size_t i = 0; i < t->ping_ack_count; i++) {
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c
index 64bdceb211..1187e59e6c 100644
--- a/test/core/end2end/end2end_nosec_tests.c
+++ b/test/core/end2end/end2end_nosec_tests.c
@@ -49,6 +49,8 @@ extern void authority_not_supported(grpc_end2end_test_config config);
extern void authority_not_supported_pre_init(void);
extern void bad_hostname(grpc_end2end_test_config config);
extern void bad_hostname_pre_init(void);
+extern void bad_ping(grpc_end2end_test_config config);
+extern void bad_ping_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
extern void cancel_after_accept(grpc_end2end_test_config config);
@@ -154,6 +156,7 @@ void grpc_end2end_tests_pre_init(void) {
grpc_summon_debugger_macros();
authority_not_supported_pre_init();
bad_hostname_pre_init();
+ bad_ping_pre_init();
binary_metadata_pre_init();
cancel_after_accept_pre_init();
cancel_after_client_done_pre_init();
@@ -214,6 +217,7 @@ void grpc_end2end_tests(int argc, char **argv,
if (argc <= 1) {
authority_not_supported(config);
bad_hostname(config);
+ bad_ping(config);
binary_metadata(config);
cancel_after_accept(config);
cancel_after_client_done(config);
@@ -275,6 +279,10 @@ void grpc_end2end_tests(int argc, char **argv,
bad_hostname(config);
continue;
}
+ if (0 == strcmp("bad_ping", argv[i])) {
+ bad_ping(config);
+ continue;
+ }
if (0 == strcmp("binary_metadata", argv[i])) {
binary_metadata(config);
continue;
diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c
index 37c1be4133..966031af65 100644
--- a/test/core/end2end/end2end_tests.c
+++ b/test/core/end2end/end2end_tests.c
@@ -49,6 +49,8 @@ extern void authority_not_supported(grpc_end2end_test_config config);
extern void authority_not_supported_pre_init(void);
extern void bad_hostname(grpc_end2end_test_config config);
extern void bad_hostname_pre_init(void);
+extern void bad_ping(grpc_end2end_test_config config);
+extern void bad_ping_pre_init(void);
extern void binary_metadata(grpc_end2end_test_config config);
extern void binary_metadata_pre_init(void);
extern void call_creds(grpc_end2end_test_config config);
@@ -156,6 +158,7 @@ void grpc_end2end_tests_pre_init(void) {
grpc_summon_debugger_macros();
authority_not_supported_pre_init();
bad_hostname_pre_init();
+ bad_ping_pre_init();
binary_metadata_pre_init();
call_creds_pre_init();
cancel_after_accept_pre_init();
@@ -217,6 +220,7 @@ void grpc_end2end_tests(int argc, char **argv,
if (argc <= 1) {
authority_not_supported(config);
bad_hostname(config);
+ bad_ping(config);
binary_metadata(config);
call_creds(config);
cancel_after_accept(config);
@@ -279,6 +283,10 @@ void grpc_end2end_tests(int argc, char **argv,
bad_hostname(config);
continue;
}
+ if (0 == strcmp("bad_ping", argv[i])) {
+ bad_ping(config);
+ continue;
+ }
if (0 == strcmp("binary_metadata", argv[i])) {
binary_metadata(config);
continue;
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 3c5068ff3e..d1e510d636 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -93,6 +93,7 @@ LOWCPU = 0.1
END2END_TESTS = {
'authority_not_supported': default_test_options,
'bad_hostname': default_test_options,
+ 'bad_ping': connectivity_test_options._replace(proxyable=False),
'binary_metadata': default_test_options,
'resource_quota_server': default_test_options._replace(large_writes=True,
proxyable=False),
diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl
index 1041219f03..dc0925dc9c 100755
--- a/test/core/end2end/generate_tests.bzl
+++ b/test/core/end2end/generate_tests.bzl
@@ -85,6 +85,7 @@ def test_options(needs_fullstack=False, needs_dns=False, proxyable=True,
# maps test names to options
END2END_TESTS = {
'bad_hostname': test_options(),
+ 'bad_ping': test_options(),
'binary_metadata': test_options(),
'resource_quota_server': test_options(proxyable=False),
'call_creds': test_options(secure=True),
diff --git a/test/core/end2end/tests/bad_ping.c b/test/core/end2end/tests/bad_ping.c
new file mode 100644
index 0000000000..01a6aeaa04
--- /dev/null
+++ b/test/core/end2end/tests/bad_ping.c
@@ -0,0 +1,237 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+
+#include "test/core/end2end/cq_verifier.h"
+
+#define MAX_PING_STRIKES 1
+
+static void *tag(intptr_t t) { return (void *)t; }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5),
+ NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+static void test_bad_ping(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_arg client_a[] = {{.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS,
+ .value.integer = 0},
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA,
+ .value.integer = 20},
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_BDP_PROBE,
+ .value.integer = 0}};
+ grpc_arg server_a[] = {
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MIN_PING_INTERVAL_WITHOUT_DATA_MS,
+ .value.integer = 300000 /* 5 minutes */},
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MAX_PING_STRIKES,
+ .value.integer = MAX_PING_STRIKES}};
+ grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a),
+ .args = client_a};
+ grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
+ .args = server_a};
+
+ config.init_client(&f, &client_args);
+ config.init_server(&f, &server_args);
+
+ grpc_call *c;
+ grpc_call *s;
+ gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ grpc_slice details;
+ int was_cancelled = 2;
+
+ c = grpc_channel_create_call(
+ f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"),
+ get_host_override_slice("foo.test.google.fr:1234", config), deadline,
+ NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->data.send_initial_metadata.metadata = NULL;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ // Send too many pings to the server to trigger the punishment:
+ // The first ping is sent after data frames, it won't trigger a ping strike.
+ // Each of the following pings will trigger a ping strike, and we need at
+ // least (MAX_PING_STRIKES + 1) strikes to trigger the punishment. So
+ // (MAX_PING_STRIKES + 2) pings are needed here.
+ int i;
+ for (i = 200; i < 202 + MAX_PING_STRIKES; i++) {
+ grpc_channel_ping(f.client, f.cq, tag(i), NULL);
+ CQ_EXPECT_COMPLETION(cqv, tag(i), 1);
+ cq_verify(cqv);
+ }
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+ grpc_slice status_details = grpc_slice_from_static_string("xyz");
+ op->data.send_status_from_server.status_details = &status_details;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
+ CQ_EXPECT_COMPLETION(cqv, tag(0xdead), 1);
+ cq_verify(cqv);
+
+ grpc_call_destroy(s);
+
+ // The connection should be closed immediately after the misbehaved pings,
+ // the in-progress RPC should fail.
+ GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(details, "Endpoint read failed"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
+ validate_host_override_string("foo.test.google.fr:1234", call_details.host,
+ config);
+ GPR_ASSERT(was_cancelled == 1);
+
+ grpc_slice_unref(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+ grpc_call_destroy(c);
+ cq_verifier_destroy(cqv);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void bad_ping(grpc_end2end_test_config config) {
+ GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_bad_ping(config);
+}
+
+void bad_ping_pre_init(void) {}
diff --git a/test/core/end2end/tests/keepalive_timeout.c b/test/core/end2end/tests/keepalive_timeout.c
index b2252dc802..bf6ca0d9d9 100644
--- a/test/core/end2end/tests/keepalive_timeout.c
+++ b/test/core/end2end/tests/keepalive_timeout.c
@@ -112,10 +112,10 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
grpc_arg keepalive_args[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_CLIENT_KEEPALIVE_TIME_S,
- .value.integer = 2},
+ .key = GRPC_ARG_KEEPALIVE_TIME_MS,
+ .value.integer = 1500},
{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S,
+ .key = GRPC_ARG_KEEPALIVE_TIMEOUT_MS,
.value.integer = 0},
{.type = GRPC_ARG_INTEGER,
.key = GRPC_ARG_HTTP2_BDP_PROBE,
diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.c
index 082ac641f0..c51c4993e2 100644
--- a/test/core/end2end/tests/ping.c
+++ b/test/core/end2end/tests/ping.c
@@ -52,16 +52,26 @@ static void test_ping(grpc_end2end_test_config config,
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
int i;
- grpc_arg a[] = {{.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS,
- .value.integer = min_time_between_pings_ms},
- {.type = GRPC_ARG_INTEGER,
- .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA,
- .value.integer = 20}};
- grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
+ grpc_arg client_a[] = {{.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS,
+ .value.integer = 0},
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA,
+ .value.integer = 20}};
+ grpc_arg server_a[] = {
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_HTTP2_MIN_PING_INTERVAL_WITHOUT_DATA_MS,
+ .value.integer = 0},
+ {.type = GRPC_ARG_INTEGER,
+ .key = GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS,
+ .value.integer = 1}};
+ grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a),
+ .args = client_a};
+ grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a),
+ .args = server_a};
config.init_client(&f, &client_args);
- config.init_server(&f, NULL);
+ config.init_server(&f, &server_args);
grpc_channel_ping(f.client, f.cq, tag(0), NULL);
CQ_EXPECT_COMPLETION(cqv, tag(0), 0);
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index fa19aa53b1..ae5120d87c 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -7129,6 +7129,7 @@
"test/core/end2end/end2end_tests.h",
"test/core/end2end/tests/authority_not_supported.c",
"test/core/end2end/tests/bad_hostname.c",
+ "test/core/end2end/tests/bad_ping.c",
"test/core/end2end/tests/binary_metadata.c",
"test/core/end2end/tests/call_creds.c",
"test/core/end2end/tests/cancel_after_accept.c",
@@ -7204,6 +7205,7 @@
"test/core/end2end/end2end_tests.h",
"test/core/end2end/tests/authority_not_supported.c",
"test/core/end2end/tests/bad_hostname.c",
+ "test/core/end2end/tests/bad_ping.c",
"test/core/end2end/tests/binary_metadata.c",
"test/core/end2end/tests/cancel_after_accept.c",
"test/core/end2end/tests/cancel_after_client_done.c",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index b878bc1231..88bac795e4 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -5727,6 +5727,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -6927,6 +6950,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -8125,6 +8171,28 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_fakesec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -10333,6 +10401,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -11525,6 +11616,25 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_test",
+ "platforms": [
+ "linux"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -12521,6 +12631,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -13677,6 +13810,30 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -14923,6 +15080,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -16125,6 +16305,30 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_oauth2_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -21709,6 +21913,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -22909,6 +23136,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_ssl_cert_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -25141,6 +25391,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -26314,6 +26587,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_census_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -27491,6 +27787,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_compress_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -29703,6 +30022,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -30872,6 +31214,25 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "linux"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+pipe_nosec_test",
+ "platforms": [
+ "linux"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -31849,6 +32210,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_full+trace_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -32982,6 +33366,30 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_http_proxy_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -34204,6 +34612,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_load_reporting_nosec_test",
+ "platforms": [
+ "windows",
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
@@ -39621,6 +40052,29 @@
},
{
"args": [
+ "bad_ping"
+ ],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "language": "c",
+ "name": "h2_uds_nosec_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [
"binary_metadata"
],
"ci_platforms": [
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
index 5a2d6acd56..e3adf793d6 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj
@@ -159,6 +159,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_hostname.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_ping.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\binary_metadata.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\cancel_after_accept.c">
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
index 3a870b945e..cfb8d043ba 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters
@@ -13,6 +13,9 @@
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_hostname.c">
<Filter>test\core\end2end\tests</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_ping.c">
+ <Filter>test\core\end2end\tests</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\binary_metadata.c">
<Filter>test\core\end2end\tests</Filter>
</ClCompile>
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
index 4b001a751d..a67f509e25 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj
@@ -159,6 +159,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_hostname.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_ping.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\binary_metadata.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\call_creds.c">
diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
index 2eace64a89..97ba77a42e 100644
--- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
+++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters
@@ -13,6 +13,9 @@
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_hostname.c">
<Filter>test\core\end2end\tests</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\bad_ping.c">
+ <Filter>test\core\end2end\tests</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\test\core\end2end\tests\binary_metadata.c">
<Filter>test\core\end2end\tests</Filter>
</ClCompile>