diff options
| author | luwenpeng <[email protected]> | 2020-07-21 20:00:14 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2020-08-21 11:58:03 +0800 |
| commit | ddb1ccba12d463fe38a6aed93dd0656445e50f48 (patch) | |
| tree | abbbdda0676ece2bdeda7fad4954844bb42afe04 /platform/src/proxy.cpp | |
| parent | 13289d5a712ce5f91b3bc51187d11ce712335d5a (diff) | |
TSG-2612 tfe 执行 TCP Options
Diffstat (limited to 'platform/src/proxy.cpp')
| -rw-r--r-- | platform/src/proxy.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 1c5f421..832b01b 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -159,6 +159,7 @@ int tfe_proxy_fds_accept(struct tfe_proxy * ctx, int fd_downstream, int fd_upstr enum tfe_stream_proto stream_protocol; uint8_t stream_protocol_in_char = 0; + int tcp_passthrough = 0; uint16_t size = 0; int result = tfe_cmsg_get_value(cmsg, TFE_CMSG_TCP_RESTORE_PROTOCOL, (unsigned char *)&stream_protocol_in_char, @@ -174,8 +175,22 @@ int tfe_proxy_fds_accept(struct tfe_proxy * ctx, int fd_downstream, int fd_upstr tfe_stream_option_set(stream, TFE_STREAM_OPT_SESSION_TYPE, &stream_protocol, sizeof(stream_protocol)); tfe_stream_cmsg_setup(stream, cmsg); + if (ctx->tcp_options.enable_overwrite <= 0) + { + result = tfe_cmsg_get_value(cmsg, TFE_CMSG_TCP_PASSTHROUGH, (unsigned char *)&tcp_passthrough, sizeof(tcp_passthrough), &size); + if (result < 0) + { + TFE_LOG_ERROR(ctx->logger, "failed at fetch connection's tcp_passthrough from cmsg: %s", strerror(-result)); + // goto __errout; + } + else + { + TFE_LOG_DEBUG(ctx->logger, "%p: fetch tcp options, passthrough: %d", stream, tcp_passthrough); + } + } + /* FOR DEBUG */ - if (unlikely(ctx->tcp_all_passthrough)) + if (unlikely(ctx->tcp_all_passthrough) || tcp_passthrough) { bool __true = true; enum tfe_stream_proto __session_type = STREAM_PROTO_PLAIN; @@ -374,15 +389,18 @@ int tfe_proxy_config(struct tfe_proxy * proxy, const char * profile) /* TCP options, -1 means unset, we shall not call setsockopt */ MESA_load_profile_int_def(profile, "tcp", "sz_rcv_buffer", &proxy->tcp_options.sz_rcv_buffer, -1); MESA_load_profile_int_def(profile, "tcp", "sz_snd_buffer", &proxy->tcp_options.sz_snd_buffer, -1); - MESA_load_profile_int_def(profile, "tcp", "so_keepalive", &proxy->tcp_options.so_keepalive, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_keepidle", &proxy->tcp_options.tcp_keepidle, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_keepintvl", &proxy->tcp_options.tcp_keepintvl, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_keepcnt", &proxy->tcp_options.tcp_keepcnt, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_user_timeout", &proxy->tcp_options.tcp_user_timeout, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_ttl_upstream", &proxy->tcp_options.tcp_ttl_upstream, -1); - MESA_load_profile_int_def(profile, "tcp", "tcp_ttl_downstream", &proxy->tcp_options.tcp_ttl_downstream, -1); - return 0; + MESA_load_profile_int_def(profile, "tcp", "enable_overwrite", &proxy->tcp_options.enable_overwrite, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_nodelay", &proxy->tcp_options.tcp_nodelay, -1); + MESA_load_profile_int_def(profile, "tcp", "so_keepalive", &proxy->tcp_options.so_keepalive, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_keepidle", &proxy->tcp_options.tcp_keepidle, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_keepintvl", &proxy->tcp_options.tcp_keepintvl, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_keepcnt", &proxy->tcp_options.tcp_keepcnt, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_user_timeout", &proxy->tcp_options.tcp_user_timeout, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_ttl_upstream", &proxy->tcp_options.tcp_ttl_upstream, -1); + MESA_load_profile_int_def(profile, "tcp", "tcp_ttl_downstream", &proxy->tcp_options.tcp_ttl_downstream, -1); + + return 0; } static const char * __str_stat_spec_map[] = |
