1 /** @file 2 3 A brief file description 4 5 @section license License 6 7 Licensed to the Apache Software Foundation (ASF) under one 8 or more contributor license agreements. See the NOTICE file 9 distributed with this work for additional information 10 regarding copyright ownership. The ASF licenses this file 11 to you under the Apache License, Version 2.0 (the 12 "License"); you may not use this file except in compliance 13 with the License. You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 */ 23 24 /**************************************************************************** 25 26 Net Subsystem 27 28 29 **************************************************************************/ 30 #pragma once 31 32 // Net Stats 33 34 enum Net_Stats { 35 net_handler_run_stat, 36 net_read_bytes_stat, 37 net_write_bytes_stat, 38 net_connections_currently_open_stat, 39 net_accepts_currently_open_stat, 40 net_calls_to_readfromnet_stat, 41 net_calls_to_readfromnet_afterpoll_stat, 42 net_calls_to_read_stat, 43 net_calls_to_read_nodata_stat, 44 net_calls_to_writetonet_stat, 45 net_calls_to_writetonet_afterpoll_stat, 46 net_calls_to_write_stat, 47 net_calls_to_write_nodata_stat, 48 socks_connections_successful_stat, 49 socks_connections_unsuccessful_stat, 50 socks_connections_currently_open_stat, 51 inactivity_cop_lock_acquire_failure_stat, 52 keep_alive_queue_timeout_total_stat, 53 keep_alive_queue_timeout_count_stat, 54 default_inactivity_timeout_applied_stat, 55 default_inactivity_timeout_count_stat, 56 net_fastopen_attempts_stat, 57 net_fastopen_successes_stat, 58 net_tcp_accept_stat, 59 net_connections_throttled_in_stat, 60 net_connections_throttled_out_stat, 61 net_requests_max_throttled_in_stat, 62 Net_Stat_Count 63 }; 64 65 struct RecRawStatBlock; 66 extern RecRawStatBlock *net_rsb; 67 #define SSL_HANDSHAKE_WANT_READ 6 68 #define SSL_HANDSHAKE_WANT_WRITE 7 69 #define SSL_HANDSHAKE_WANT_ACCEPT 8 70 #define SSL_HANDSHAKE_WANT_CONNECT 9 71 72 #define NET_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, 1) 73 74 #define NET_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, -1) 75 76 #define NET_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, _r) 77 78 #define NET_READ_DYN_SUM(_x, _sum) RecGetRawStatSum(net_rsb, (int)_x, &_sum) 79 80 #define NET_READ_DYN_STAT(_x, _count, _sum) \ 81 do { \ 82 RecGetRawStatSum(net_rsb, (int)_x, &_sum); \ 83 RecGetRawStatCount(net_rsb, (int)_x, &_count); \ 84 } while (0) 85 86 #define NET_CLEAR_DYN_STAT(x) \ 87 do { \ 88 RecSetRawStatSum(net_rsb, x, 0); \ 89 RecSetRawStatCount(net_rsb, x, 0); \ 90 } while (0); 91 92 // For global access 93 #define NET_SUM_GLOBAL_DYN_STAT(_x, _r) RecIncrGlobalRawStatSum(net_rsb, (_x), (_r)) 94 #define NET_READ_GLOBAL_DYN_SUM(_x, _sum) RecGetGlobalRawStatSum(net_rsb, _x, &_sum) 95 96 #include "tscore/ink_platform.h" 97 #include "P_EventSystem.h" 98 #include "I_Net.h" 99 #include "P_NetVConnection.h" 100 #include "P_UnixNet.h" 101 #include "P_UnixNetProcessor.h" 102 #include "P_NetAccept.h" 103 #include "P_UnixNetVConnection.h" 104 #include "P_UnixPollDescriptor.h" 105 #include "P_Socks.h" 106 #include "P_CompletionUtil.h" 107 #include "P_NetVCTest.h" 108 109 #include "P_SSLNetVConnection.h" 110 #include "P_SSLNetProcessor.h" 111 #include "P_SSLNetAccept.h" 112 #include "P_SSLCertLookup.h" 113 114 static constexpr ts::ModuleVersion NET_SYSTEM_MODULE_INTERNAL_VERSION(NET_SYSTEM_MODULE_PUBLIC_VERSION, ts::ModuleVersion::PRIVATE); 115 116 // For very verbose iocore debugging. 117 #ifndef DEBUG 118 #define NetDebug(tag, fmt, ...) 119 #else 120 #define NetDebug(tag, fmt, ...) Debug(tag, fmt, ##__VA_ARGS__) 121 #endif 122 123 /// Default amount of buffer space to use for the initial read on an incoming connection. 124 /// This is an IOBufferBlock index, not the size in bytes. 125 static size_t const CLIENT_CONNECTION_FIRST_READ_BUFFER_SIZE_INDEX = BUFFER_SIZE_INDEX_4K; 126