Skip to content

Commit 0ff58c3

Browse files
committed
treewide: tidy local variables to lower_case
Signed-off-by: Jarno Rajahalme <[email protected]>
1 parent 8783778 commit 0ff58c3

14 files changed

+77
-75
lines changed

.clang-tidy

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ CheckOptions:
106106
value: 'CamelCase'
107107
- key: readability-identifier-naming.FunctionCase
108108
value: 'camelBack'
109+
- key: readability-identifier-naming.LocalVariableCase
110+
value: 'lower_case'
109111

110112
HeaderFilterRegex: '^./source/.*|^./contrib/.*|^./test/.*|^./envoy/.*'
111113

cilium/bpf_metadata.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,28 @@ uint32_t Config::resolveSourceIdentity(const PolicyInstance& policy,
300300
IPAddressPair
301301
Config::getIPAddressPairFrom(const Network::Address::InstanceConstSharedPtr source_address,
302302
const IPAddressPair& addresses) {
303-
auto addressPair = IPAddressPair();
303+
auto address_pair = IPAddressPair();
304304

305305
switch (source_address->ip()->version()) {
306306
case Network::Address::IpVersion::v4:
307-
addressPair.ipv4_ = source_address;
307+
address_pair.ipv4_ = source_address;
308308
if (addresses.ipv6_) {
309309
sockaddr_in6 sa6 = *reinterpret_cast<const sockaddr_in6*>(addresses.ipv6_->sockAddr());
310310
sa6.sin6_port = htons(source_address->ip()->port());
311-
addressPair.ipv6_ = std::make_shared<Network::Address::Ipv6Instance>(sa6);
311+
address_pair.ipv6_ = std::make_shared<Network::Address::Ipv6Instance>(sa6);
312312
}
313313
break;
314314
case Network::Address::IpVersion::v6:
315-
addressPair.ipv6_ = source_address;
315+
address_pair.ipv6_ = source_address;
316316
if (addresses.ipv4_) {
317317
sockaddr_in sa4 = *reinterpret_cast<const sockaddr_in*>(addresses.ipv4_->sockAddr());
318318
sa4.sin_port = htons(source_address->ip()->port());
319-
addressPair.ipv4_ = std::make_shared<Network::Address::Ipv4Instance>(&sa4);
319+
address_pair.ipv4_ = std::make_shared<Network::Address::Ipv4Instance>(&sa4);
320320
}
321321
break;
322322
}
323323

324-
return addressPair;
324+
return address_pair;
325325
}
326326

327327
const Network::Address::Ip* Config::selectIPVersion(const Network::Address::IpVersion version,

cilium/host_map.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ namespace Cilium {
3232

3333
template <typename T>
3434
unsigned int checkPrefix(T addr, bool have_prefix, unsigned int plen, absl::string_view host) {
35-
const unsigned int PLEN_MAX = sizeof(T) * 8;
35+
const unsigned int plen_max = sizeof(T) * 8;
3636
if (!have_prefix) {
37-
return PLEN_MAX;
37+
return plen_max;
3838
}
39-
if (plen > PLEN_MAX) {
39+
if (plen > plen_max) {
4040
throw EnvoyException(fmt::format("NetworkPolicyHosts: Invalid prefix length in \'{}\'", host));
4141
}
4242
// Check for 1-bits after the prefix
43-
if ((plen == 0 && addr) || (plen > 0 && addr & ntoh((T(1) << (PLEN_MAX - plen)) - 1))) {
43+
if ((plen == 0 && addr) || (plen > 0 && addr & ntoh((T(1) << (plen_max - plen)) - 1))) {
4444
throw EnvoyException(fmt::format("NetworkPolicyHosts: Non-prefix bits set in \'{}\'", host));
4545
}
4646
return plen;

cilium/host_map.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ template <> inline absl::uint128 hton(absl::uint128 addr) {
6262
}
6363

6464
template <typename I> I masked(I addr, unsigned int plen) {
65-
const unsigned int PLEN_MAX = sizeof(I) * 8;
66-
return plen == 0 ? I(0) : addr & ~hton((I(1) << (PLEN_MAX - plen)) - 1);
65+
const unsigned int plen_max = sizeof(I) * 8;
66+
return plen == 0 ? I(0) : addr & ~hton((I(1) << (plen_max - plen)) - 1);
6767
};
6868

6969
class PolicyHostDecoder : public Envoy::Config::OpaqueResourceDecoder {

cilium/l7policy.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ Http::FilterHeadersStatus AccessFilter::encodeHeaders(Http::ResponseHeaderMap& h
282282
if (!log_entry_->request_logged_) {
283283
// Default logging local errors as "forwarded".
284284
// The response log will contain the locally generated HTTP error code.
285-
auto logType = ::cilium::EntryType::Request;
285+
auto log_type = ::cilium::EntryType::Request;
286286

287287
if (headers.Status()->value() == "403") {
288288
// Log as a denied request.
289-
logType = ::cilium::EntryType::Denied;
289+
log_type = ::cilium::EntryType::Denied;
290290
config_->stats_.access_denied_.inc();
291291
}
292-
config_->log(*log_entry_, logType);
292+
config_->log(*log_entry_, log_type);
293293
}
294294

295295
// Log the response

cilium/network_filter.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,19 @@ Network::FilterStatus Instance::onNewConnection() {
122122
// Pass metadata from tls_inspector to the filterstate, if any & not already
123123
// set via upstream cluster config.
124124
if (!sni.empty()) {
125-
auto filterState = conn.streamInfo().filterState();
125+
auto filter_state = conn.streamInfo().filterState();
126126
auto have_sni =
127-
filterState->hasData<Network::UpstreamServerName>(Network::UpstreamServerName::key());
128-
auto have_san = filterState->hasData<Network::UpstreamSubjectAltNames>(
127+
filter_state->hasData<Network::UpstreamServerName>(Network::UpstreamServerName::key());
128+
auto have_san = filter_state->hasData<Network::UpstreamSubjectAltNames>(
129129
Network::UpstreamSubjectAltNames::key());
130130
if (!have_sni && !have_san) {
131-
filterState->setData(Network::UpstreamServerName::key(),
132-
std::make_unique<Network::UpstreamServerName>(sni),
133-
StreamInfo::FilterState::StateType::Mutable);
134-
filterState->setData(Network::UpstreamSubjectAltNames::key(),
135-
std::make_unique<Network::UpstreamSubjectAltNames>(
136-
std::vector<std::string>{std::string(sni)}),
137-
StreamInfo::FilterState::StateType::Mutable);
131+
filter_state->setData(Network::UpstreamServerName::key(),
132+
std::make_unique<Network::UpstreamServerName>(sni),
133+
StreamInfo::FilterState::StateType::Mutable);
134+
filter_state->setData(Network::UpstreamSubjectAltNames::key(),
135+
std::make_unique<Network::UpstreamSubjectAltNames>(
136+
std::vector<std::string>{std::string(sni)}),
137+
StreamInfo::FilterState::StateType::Mutable);
138138
}
139139
}
140140

cilium/network_policy.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ namespace Cilium {
5959
uint64_t NetworkPolicyMap::instance_id_ = 0;
6060

6161
IPAddressPair::IPAddressPair(const cilium::NetworkPolicy& proto) {
62-
for (const auto& ipAddr : proto.endpoint_ips()) {
63-
auto ip = Network::Utility::parseInternetAddressNoThrow(ipAddr);
62+
for (const auto& ip_addr : proto.endpoint_ips()) {
63+
auto ip = Network::Utility::parseInternetAddressNoThrow(ip_addr);
6464
if (ip) {
6565
switch (ip->ip()->version()) {
6666
case Network::Address::IpVersion::v4:
@@ -111,8 +111,8 @@ class HeaderMatch : public Logger::Loggable<Logger::Id::config> {
111111
}
112112

113113
// Perform presence match if the value to match is empty
114-
bool isPresentMatch = match_value->length() == 0;
115-
if (isPresentMatch) {
114+
bool is_present_match = match_value->length() == 0;
115+
if (is_present_match) {
116116
matches = header_value.result().has_value();
117117
} else if (header_value.result().has_value()) {
118118
const absl::string_view val = header_value.result().value();
@@ -151,7 +151,7 @@ class HeaderMatch : public Logger::Loggable<Logger::Id::config> {
151151
logMissing(log_entry, *match_value);
152152
return true;
153153
case cilium::HeaderMatch::DELETE_ON_MISMATCH:
154-
if (isPresentMatch) {
154+
if (is_present_match) {
155155
// presence match failed, nothing to do
156156
return true;
157157
}
@@ -1372,12 +1372,12 @@ ProtobufTypes::MessagePtr
13721372
NetworkPolicyMap::dumpNetworkPolicyConfigs(const Matchers::StringMatcher& name_matcher) {
13731373
ENVOY_LOG(debug, "Writing NetworkPolicies to NetworkPoliciesConfigDump");
13741374

1375-
std::vector<uint64_t> policyEndpointIds;
1375+
std::vector<uint64_t> policy_endpoint_ids;
13761376
auto config_dump = std::make_unique<cilium::NetworkPoliciesConfigDump>();
13771377
for (const auto& item : *load()) {
13781378
// filter duplicates (policies are stored per endpoint ip)
1379-
if (std::find(policyEndpointIds.begin(), policyEndpointIds.end(),
1380-
item.second->policy_proto_.endpoint_id()) != policyEndpointIds.end()) {
1379+
if (std::find(policy_endpoint_ids.begin(), policy_endpoint_ids.end(),
1380+
item.second->policy_proto_.endpoint_id()) != policy_endpoint_ids.end()) {
13811381
continue;
13821382
}
13831383

@@ -1386,7 +1386,7 @@ NetworkPolicyMap::dumpNetworkPolicyConfigs(const Matchers::StringMatcher& name_m
13861386
}
13871387

13881388
config_dump->mutable_networkpolicies()->Add()->CopyFrom(item.second->policy_proto_);
1389-
policyEndpointIds.emplace_back(item.second->policy_proto_.endpoint_id());
1389+
policy_endpoint_ids.emplace_back(item.second->policy_proto_.endpoint_id());
13901390
}
13911391

13921392
return config_dump;

cilium/socket_option_ip_transparent.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ bool IpTransparentSocketOption::setOption(
3232

3333
auto& cilium_calls = PrivilegedService::Singleton::get();
3434

35-
auto ipVersion = socket.ipVersion();
36-
if (!ipVersion.has_value()) {
35+
auto ip_version = socket.ipVersion();
36+
if (!ip_version.has_value()) {
3737
ENVOY_LOG(critical, "Socket address family is not available, can not choose source address");
3838
return false;
3939
}
@@ -44,7 +44,7 @@ bool IpTransparentSocketOption::setOption(
4444
auto ip_socket_level = SOL_IP;
4545
auto ip_transparent_socket_option = IP_TRANSPARENT;
4646
auto ip_transparent_socket_option_name = "IP_TRANSPARENT";
47-
if (*ipVersion == Network::Address::IpVersion::v6) {
47+
if (*ip_version == Network::Address::IpVersion::v6) {
4848
ip_socket_level = SOL_IPV6;
4949
ip_transparent_socket_option = IPV6_TRANSPARENT;
5050
ip_transparent_socket_option_name = "IPV6_TRANSPARENT";

cilium/socket_option_source_address.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool SourceAddressSocketOption::setOption(
4040
return true;
4141
}
4242

43-
auto ipVersion = socket.ipVersion();
44-
if (!ipVersion.has_value()) {
43+
auto ip_version = socket.ipVersion();
44+
if (!ip_version.has_value()) {
4545
ENVOY_LOG(critical, "Socket address family is not available, can not choose source address");
4646
return false;
4747
}
@@ -50,7 +50,7 @@ bool SourceAddressSocketOption::setOption(
5050
if (!source_address && (ipv4_source_address_ || ipv6_source_address_)) {
5151
// Select source address based on the socket address family
5252
source_address = ipv6_source_address_;
53-
if (*ipVersion == Network::Address::IpVersion::v4) {
53+
if (*ip_version == Network::Address::IpVersion::v4) {
5454
source_address = ipv4_source_address_;
5555
}
5656
}

cilium/tls_wrapper.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,28 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable<Logge
155155
} else {
156156
policy.tlsWrapperMissingPolicyInc();
157157

158-
std::string ipStr("<none>");
158+
std::string ip_str("<none>");
159159
if (policy_ref->ingress_) {
160160
Network::Address::InstanceConstSharedPtr src_address =
161161
is_client ? callbacks_->connection().connectionInfoProvider().localAddress()
162162
: callbacks_->connection().connectionInfoProvider().remoteAddress();
163163
if (src_address) {
164164
const auto sip = src_address->ip();
165165
if (sip) {
166-
ipStr = sip->addressAsString();
166+
ip_str = sip->addressAsString();
167167
}
168168
}
169169
} else {
170170
if (dip) {
171-
ipStr = dip->addressAsString();
171+
ip_str = dip->addressAsString();
172172
}
173173
}
174174
ENVOY_CONN_LOG(
175175
warn,
176176
"cilium.tls_wrapper: Could not get {} TLS context for pod {} on {} IP {} (id {}) port "
177177
"{} sni \"{}\" and raw socket is not allowed",
178178
conn, is_client ? "client" : "server", policy_ref->pod_ip_,
179-
policy_ref->ingress_ ? "source" : "destination", ipStr, remote_id, destination_port,
179+
policy_ref->ingress_ ? "source" : "destination", ip_str, remote_id, destination_port,
180180
sni);
181181
}
182182
} else {

tests/cilium_tls_http_integration_test.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ class CiliumHttpTLSIntegrationTest : public CiliumHttpIntegrationTest {
240240
Network::Address::InstanceConstSharedPtr address =
241241
Ssl::getSslAddress(version_, lookupPort("http"));
242242
context_ = createClientSslTransportSocketFactory(context_manager_, *api_);
243-
Network::ClientConnectionPtr ssl_client_ = dispatcher_->createClientConnection(
243+
Network::ClientConnectionPtr ssl_client = dispatcher_->createClientConnection(
244244
address, Network::Address::InstanceConstSharedPtr(),
245245
context_->createTransportSocket(nullptr, nullptr), nullptr, nullptr);
246246

247-
ssl_client_->enableHalfClose(true);
248-
codec_client_ = makeHttpConnection(std::move(ssl_client_));
247+
ssl_client->enableHalfClose(true);
248+
codec_client_ = makeHttpConnection(std::move(ssl_client));
249249
}
250250

251251
void createUpstreams() override {

tests/cilium_websocket_decap_integration_test.cc

+21-21
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
156156
response->waitForHeaders();
157157
EXPECT_EQ("101", response->headers().getStatusValue());
158158

159-
auto clientConn = codec_client_->connection();
159+
auto client_conn = codec_client_->connection();
160160

161161
// Create websocket framed data & write it on the client connection
162162
Buffer::OwnedImpl buf{"\x82\x5"
163163
"hello"};
164-
clientConn->write(buf, false);
164+
client_conn->write(buf, false);
165165
// Run the dispatcher so that the write event is handled
166-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
166+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
167167

168168
std::string data;
169169
ASSERT_TRUE(fake_upstream_connection->waitForData(5, &data));
@@ -187,9 +187,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
187187
"hello21"
188188
"\x82\x3"
189189
"foo");
190-
clientConn->write(buf, false);
190+
client_conn->write(buf, false);
191191
// Run the dispatcher so that the write event is handled
192-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
192+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
193193

194194
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 16, &data));
195195
ASSERT_EQ(data.substr(seen_data_len), "hello2hello21foo");
@@ -211,9 +211,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
211211
"len16",
212212
9};
213213
buf.add(frame16);
214-
clientConn->write(buf, false);
214+
client_conn->write(buf, false);
215215
// Run the dispatcher so that the write event is handled
216-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
216+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
217217

218218
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 5, &data));
219219
ASSERT_EQ(data.substr(seen_data_len), "len16");
@@ -238,9 +238,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
238238
"len64",
239239
15};
240240
buf.add(frame64);
241-
clientConn->write(buf, false);
241+
client_conn->write(buf, false);
242242
// Run the dispatcher so that the write event is handled
243-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
243+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
244244

245245
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 5, &data));
246246
ASSERT_EQ(data.substr(seen_data_len), "len64");
@@ -259,9 +259,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
259259
"hello"
260260
"\x82\xe"
261261
"gap ");
262-
clientConn->write(buf, false);
262+
client_conn->write(buf, false);
263263
// Run the dispatcher so that the write event is handled
264-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
264+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
265265

266266
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 9, &data));
267267
ASSERT_EQ(data.substr(seen_data_len), "hellogap ");
@@ -273,9 +273,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
273273
buf.add("in between"
274274
"\x82\x3"
275275
"foo");
276-
clientConn->write(buf, false);
276+
client_conn->write(buf, false);
277277
// Run the dispatcher so that the write event is handled
278-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
278+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
279279

280280
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 13, &data));
281281
ASSERT_EQ(data.substr(seen_data_len), "in betweenfoo");
@@ -298,9 +298,9 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
298298
buf.add("\x82\x8e");
299299
buf.add(mask, 4);
300300
buf.add(masked.data(), masked.length());
301-
clientConn->write(buf, false);
301+
client_conn->write(buf, false);
302302
// Run the dispatcher so that the write event is handled
303-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
303+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
304304

305305
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 14, &data));
306306
ASSERT_EQ(data.substr(seen_data_len), msg);
@@ -326,25 +326,25 @@ TEST_P(CiliumWebSocketIntegrationTest, AcceptedWebSocket) {
326326
// Write frame header
327327
buf.add("\x82\x8d");
328328
buf.add(mask2, 4);
329-
clientConn->write(buf, false);
329+
client_conn->write(buf, false);
330330
// Run the dispatcher so that the write event is handled
331-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
331+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
332332

333333
// Write 5 first bytes
334334
buf.add(masked2.data(), 5);
335-
clientConn->write(buf, false);
335+
client_conn->write(buf, false);
336336
// Run the dispatcher so that the write event is handled
337-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
337+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
338338

339339
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 5, &data));
340340
ASSERT_EQ(data.substr(seen_data_len), absl::string_view(msg2.data(), 5));
341341
seen_data_len = data.length();
342342

343343
// Write remaining bytes
344344
buf.add(masked2.data() + 5, masked2.length() - 5);
345-
clientConn->write(buf, false);
345+
client_conn->write(buf, false);
346346
// Run the dispatcher so that the write event is handled
347-
clientConn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
347+
client_conn->dispatcher().run(Event::Dispatcher::RunType::NonBlock);
348348

349349
ASSERT_TRUE(fake_upstream_connection->waitForData(seen_data_len + 13 - 5, &data));
350350
ASSERT_EQ(data.substr(seen_data_len), msg2.data() + 5);

0 commit comments

Comments
 (0)