forked from pixie-io/pixie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLEANUP] Move CPP code inside common.h to common.hpp
Summary: Bundled here is a minor change in conn_id_t's ToString(), where upid is now printed as one unit, from: pid=%d start_time_ticks=%d to upid=%d:%d This reduces the length of CONN_TRACE() logs. Test Plan: Since this just moves code between files, the existing tests already cover them Reviewers: #stirling, oazizi Reviewed By: #stirling, oazizi Signed-off-by: yzhao1012 <yzhao@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D10743 GitOrigin-RevId: a3d1e11
- Loading branch information
1 parent
271b0be
commit 1d00d0b
Showing
7 changed files
with
81 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/stirling/source_connectors/socket_tracer/bcc_bpf_intf/common.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2018- The Pixie Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "src/stirling/source_connectors/socket_tracer/bcc_bpf_intf/common.hpp" | ||
|
||
#include <algorithm> | ||
#include <map> | ||
#include <string> | ||
|
||
#include <absl/strings/substitute.h> | ||
#include <magic_enum.hpp> | ||
|
||
#include "src/common/base/enum_utils.h" | ||
#include "src/stirling/source_connectors/socket_tracer/bcc_bpf_intf/common.h" | ||
|
||
constexpr int kNumProtocols = magic_enum::enum_count<traffic_protocol_t>(); | ||
|
||
static const std::map<int64_t, std::string_view> kTrafficProtocolDecoder = | ||
px::EnumDefToMap<traffic_protocol_t>(); | ||
|
||
static const std::map<int64_t, std::string_view> kEndpointRoleDecoder = | ||
px::EnumDefToMap<endpoint_role_t>(); | ||
|
||
inline std::string ToString(const conn_id_t& conn_id) { | ||
return absl::Substitute("[upid=$0:$1 fd=$2 gen=$3]", conn_id.upid.pid, | ||
conn_id.upid.start_time_ticks, conn_id.fd, conn_id.tsid); | ||
} | ||
|
||
inline bool operator==(const struct conn_id_t& a, const struct conn_id_t& b) { | ||
return a.upid == b.upid && a.fd == b.fd && a.tsid == b.tsid; | ||
} | ||
|
||
inline bool operator!=(const struct conn_id_t& a, const struct conn_id_t& b) { return !(a == b); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters