-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ebpf plugins #2049
Open
KayzzzZ
wants to merge
46
commits into
alibaba:dev/ebpf_observe
Choose a base branch
from
KayzzzZ:ql/add-coolbpf
base: dev/ebpf_observe
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+22,864
−1,860
Open
feat: add ebpf plugins #2049
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
d6e1030
add some utils
KayzzzZ 04f6599
add protocol parser and aggregator
KayzzzZ d4aafbd
1. add some third party utils
KayzzzZ c290c30
update coolbpf and add driver layer framework
KayzzzZ feeb539
compile coolbpf and driver lib
KayzzzZ b575f94
export some functions for driver
KayzzzZ ca8b008
network observer start done ..
KayzzzZ bdd653d
network observer support log scenario
KayzzzZ a660ac8
fix enterprise compile
KayzzzZ 0186592
update
KayzzzZ e9b9297
move id allocator
KayzzzZ 96a4cca
format && add some framework
KayzzzZ cf01f07
update
KayzzzZ 58962e7
update
KayzzzZ b438364
update
KayzzzZ 697b82c
update
KayzzzZ 58ad778
update
KayzzzZ 497b097
add aggregator ut and setup aggregator for networksecurity & filesecu…
KayzzzZ fa8bee1
add some annotations
KayzzzZ 6313b5e
add lock
KayzzzZ 0374e83
add data handler
KayzzzZ 08b5201
update
KayzzzZ cdf4ff3
update
KayzzzZ 65cca2c
fix conflict
KayzzzZ 3176f41
update
KayzzzZ 978b903
flush span
KayzzzZ 4d15e92
fix url path
KayzzzZ 0f916e7
set to event tag instead of event group tag
KayzzzZ 3545ec5
update
KayzzzZ 10217de
clang format
KayzzzZ 364dbc2
add some unittests
KayzzzZ 96f80a9
clone event
KayzzzZ 8c0850b
rebase main
KayzzzZ ed80d72
update coolbpf
KayzzzZ 0c94a5a
fix
KayzzzZ 823a4f1
update
KayzzzZ 3a6b2b1
Update submodule coolbpf to commit c24d3993c16051c00d86eae063958898e4…
yyuuttaaoo 9696ee8
try to fix compile failed with -std=c90
yyuuttaaoo 68ba6eb
fix stadalone binary compile issue with compatible mode
yyuuttaaoo 6ab0ab9
fix build script
yyuuttaaoo 08afa01
Merge remote-tracking branch 'upstream/main' into ql/add-coolbpf
yyuuttaaoo 3503e15
add some uts
KayzzzZ e99eee7
fix timer unittest
KayzzzZ 6c56bf6
enable privileged
KayzzzZ 272b8cc
fix ut
KayzzzZ 5bc8c4b
fix log format string and remove useless files
yyuuttaaoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "core/ebpf/driver/coolbpf"] | ||
path = core/ebpf/driver/coolbpf | ||
url = https://gitee.com/anolis/coolbpf.git |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,12 @@ DEFINE_FLAG_STRING(metrics_report_method, | |
DEFINE_FLAG_STRING(operator_service, "loong collector operator service", ""); | ||
DEFINE_FLAG_INT32(operator_service_port, "loong collector operator service port", 8888); | ||
DEFINE_FLAG_INT32(k8s_meta_service_port, "loong collector operator service port", 9000); | ||
|
||
DEFINE_FLAG_STRING(loong_collector_singleton_service, "loong collector singleton service", "loongcollector-singleton"); | ||
DEFINE_FLAG_INT32(loong_collector_singleton_port, "loong collector singleton service port", 8899); | ||
DEFINE_FLAG_STRING(loong_collector_operator_service, "loong collector operator service", ""); | ||
DEFINE_FLAG_INT32(loong_collector_operator_service_port, "loong collector operator service port", 8888); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这两个和上面重复了 |
||
DEFINE_FLAG_INT32(loong_collector_k8s_meta_service_port, "loong collector operator service port", 9000); | ||
DEFINE_FLAG_STRING(_pod_name_, "agent pod name", ""); | ||
|
||
DEFINE_FLAG_STRING(app_info_file, "", "app_info.json"); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright 2023 iLogtail 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. | ||
|
||
#include "CapabilityUtil.h" | ||
#include <unordered_map> | ||
#include <vector> | ||
#include <stdexcept> | ||
#include <iostream> | ||
#include <sstream> | ||
|
||
namespace logtail { | ||
|
||
std::unordered_map<uint64_t, std::string> capabilitiesString = { | ||
{0, "CAP_CHOWN"}, | ||
{1, "DAC_OVERRIDE"}, | ||
{2, "CAP_DAC_READ_SEARCH"}, | ||
{3, "CAP_FOWNER"}, | ||
{4, "CAP_FSETID"}, | ||
{5, "CAP_KILL"}, | ||
{6, "CAP_SETGID"}, | ||
{7, "CAP_SETUID"}, | ||
{8, "CAP_SETPCAP"}, | ||
{9, "CAP_LINUX_IMMUTABLE"}, | ||
{10, "CAP_NET_BIND_SERVICE"}, | ||
{11, "CAP_NET_BROADCAST"}, | ||
{12, "CAP_NET_ADMIN"}, | ||
{13, "CAP_NET_RAW"}, | ||
{14, "CAP_IPC_LOCK"}, | ||
{15, "CAP_IPC_OWNER"}, | ||
{16, "CAP_SYS_MODULE"}, | ||
{17, "CAP_SYS_RAWIO"}, | ||
{18, "CAP_SYS_CHROOT"}, | ||
{19, "CAP_SYS_PTRACE"}, | ||
{20, "CAP_SYS_PACCT"}, | ||
{21, "CAP_SYS_ADMIN"}, | ||
{22, "CAP_SYS_BOOT"}, | ||
{23, "CAP_SYS_NICE"}, | ||
{24, "CAP_SYS_RESOURCE"}, | ||
{25, "CAP_SYS_TIME"}, | ||
{26, "CAP_SYS_TTY_CONFIG"}, | ||
{27, "CAP_MKNOD"}, | ||
{28, "CAP_LEASE"}, | ||
{29, "CAP_AUDIT_WRITE"}, | ||
{30, "CAP_AUDIT_CONTROL"}, | ||
{31, "CAP_SETFCAP"}, | ||
{32, "CAP_MAC_OVERRIDE"}, | ||
{33, "CAP_MAC_ADMIN"}, | ||
{34, "CAP_SYSLOG"}, | ||
{35, "CAP_WAKE_ALARM"}, | ||
{36, "CAP_BLOCK_SUSPEND"}, | ||
{37, "CAP_AUDIT_READ"}, | ||
{38, "CAP_PERFMON"}, | ||
{39, "CAP_BPF"}, | ||
{40, "CAP_CHECKPOINT_RESTORE"} | ||
}; | ||
|
||
const int32_t CAP_LAST_CAP = 40; | ||
|
||
bool IsCapValid(int32_t capInt) { | ||
return (capInt >= 0 && capInt <= CAP_LAST_CAP); | ||
} | ||
|
||
std::string GetCapability(int32_t capInt) { | ||
if (!IsCapValid(capInt)) { | ||
throw std::invalid_argument("invalid capability value " + std::to_string(capInt)); | ||
} | ||
|
||
auto it = capabilitiesString.find(static_cast<uint64_t>(capInt)); | ||
if (it == capabilitiesString.end()) { | ||
throw std::invalid_argument("could not map capability value " + std::to_string(capInt)); | ||
} | ||
|
||
return it->second; | ||
} | ||
|
||
std::string GetCapabilities(uint64_t capInt) { | ||
std::vector<std::string> caps; | ||
|
||
for (uint64_t i = 0; i < 64; ++i) { | ||
if ((1ULL << i) & capInt) { | ||
auto it = capabilitiesString.find(i); | ||
if (it != capabilitiesString.end()) { | ||
caps.push_back(it->second); | ||
} | ||
} | ||
} | ||
|
||
std::ostringstream oss; | ||
for (size_t i = 0; i < caps.size(); ++i) { | ||
if (i > 0) { | ||
oss << " "; | ||
} | ||
oss << caps[i]; | ||
} | ||
return oss.str(); | ||
} | ||
|
||
} |
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,25 @@ | ||
// Copyright 2023 iLogtail 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. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace logtail { | ||
|
||
std::string GetCapabilities(uint64_t capInt); | ||
|
||
std::string GetCapability(int32_t capInt); | ||
|
||
} |
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 |
---|---|---|
|
@@ -104,13 +104,9 @@ class Cache { | |
* directly anyway! :) | ||
*/ | ||
explicit Cache(size_t maxSize = 64, size_t elasticity = 10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个文件本身是不是应该放到opt目录里 |
||
: maxSize_(maxSize), elasticity_(elasticity), prune_thread(&Cache::pruneThreadFunc, this) {} | ||
: maxSize_(maxSize), elasticity_(elasticity) {} | ||
|
||
virtual ~Cache() { | ||
stop_pruning = true; | ||
if (prune_thread.joinable()) { | ||
prune_thread.join(); | ||
} | ||
} | ||
|
||
size_t size() const { | ||
|
@@ -252,13 +248,6 @@ class Cache { | |
return count; | ||
} | ||
|
||
void pruneThreadFunc() { | ||
while (!stop_pruning) { | ||
pruneExpired(); | ||
std::this_thread::sleep_for(std::chrono::seconds(60)); // 每60秒检查一次 | ||
} | ||
} | ||
|
||
private: | ||
// Disallow copying. | ||
Cache(const Cache&) = delete; | ||
|
@@ -269,8 +258,6 @@ class Cache { | |
list_type keys_; | ||
size_t maxSize_; | ||
size_t elasticity_; | ||
std::atomic<bool> stop_pruning{false}; | ||
std::thread prune_thread; | ||
|
||
#ifdef APSARA_UNIT_TEST_MAIN | ||
friend class LRUCacheUnittest; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名都去掉loong_collector_