Skip to content
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

new(sinsp-example): add gvisor support #2185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions userspace/libscap/engine/gvisor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ add_library(
scap_engine_gvisor ${scap_engine_gvisor_sources} ${scap_engine_gvisor_generated_sources}
)

add_dependencies(scap_engine_gvisor uthash jsoncpp)
add_dependencies(scap_engine_gvisor uthash jsoncpp scap_event_schema)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in an initial attempt, i tried to add gvisor to scap open but I faced a link error for scap_event_encode_params so it seems correct to link against scap_event_schema

target_link_libraries(
scap_engine_gvisor PUBLIC scap_platform_util scap_error ${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIB} ${JSONCPP_LIB}
${PROTOBUF_LIB} ${JSONCPP_LIB} scap_event_schema
)

target_include_directories(scap_engine_gvisor PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
21 changes: 19 additions & 2 deletions userspace/libsinsp/examples/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
static string filter_string = "";
static string file_path = "";
static string bpf_path = "";
static string gvisor_config_path = "/etc/docker/runsc_falco_config.json";
static unsigned long buffer_bytes_dim = DEFAULT_DRIVER_BUFFER_BYTES_DIM;
static uint64_t max_events = UINT64_MAX;
static std::shared_ptr<sinsp_plugin> plugin;
Expand Down Expand Up @@ -110,6 +111,7 @@
-b <path>, --bpf <path> BPF probe.
-m, --modern_bpf modern BPF probe.
-k, --kmod Kernel module
-G <config_path>, --gvisor <config_path> Gvisor engine
-s <path>, --scap_file <path> Scap file
-p <path>, --plugin <path> Plugin. Path can follow the pattern "filepath.so|init_cfg|open_params".
-d <dim>, --buffer_dim <dim> Dimension in bytes that every per-CPU buffer will have.
Expand Down Expand Up @@ -155,13 +157,17 @@
{"remove-io-sc-state", no_argument, 0, 'q'},
{"enable-glogger", no_argument, 0, 'g'},
{"raw", no_argument, 0, 'r'},
{"gvisor", optional_argument, 0, 'G'},
{0, 0, 0, 0}};

bool format_set = false;
int op;
int long_index = 0;
while((op = getopt_long(argc, argv, "hf:jab:mks:p:d:o:En:zxqgr", long_options, &long_index)) !=
-1) {
while((op = getopt_long(argc,

Check warning on line 166 in userspace/libsinsp/examples/test.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/examples/test.cpp#L166

Added line #L166 was not covered by tests
argv,
"hf:jab:mks:p:d:o:En:zxqgrG::",
long_options,
&long_index)) != -1) {
switch(op) {
case 'h':
usage();
Expand All @@ -186,6 +192,12 @@
select_engine(BPF_ENGINE);
bpf_path = optarg;
break;
case 'G':
engine_string = GVISOR_ENGINE;

Check warning on line 196 in userspace/libsinsp/examples/test.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/examples/test.cpp#L195-L196

Added lines #L195 - L196 were not covered by tests
if(optarg != nullptr) {
gvisor_config_path = optarg;

Check warning on line 198 in userspace/libsinsp/examples/test.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/examples/test.cpp#L198

Added line #L198 was not covered by tests
}
break;
case 'm':
select_engine(MODERN_BPF_ENGINE);
break;
Expand Down Expand Up @@ -349,6 +361,11 @@
plugin->id() == 0 ? sinsp_plugin_platform::SINSP_PLATFORM_FULL
: sinsp_plugin_platform::SINSP_PLATFORM_HOSTINFO);
}
#endif
#ifdef HAS_ENGINE_GVISOR
else if(!engine_string.compare(GVISOR_ENGINE)) {
inspector.open_gvisor(gvisor_config_path, "", false, -1);
}
#endif
else {
std::cerr << "Unknown engine" << std::endl;
Expand Down
Loading