Skip to content

Commit

Permalink
update: propagate support to sinsp
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
  • Loading branch information
Andreagit97 committed Jan 13, 2023
1 parent e50d37c commit 43b33a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion userspace/libsinsp/examples/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void open_engine(sinsp& inspector)
}
else if(!engine_string.compare(MODERN_BPF_ENGINE))
{
inspector.open_modern_bpf(buffer_bytes_dim, ppm_sc, tp_set);
inspector.open_modern_bpf(buffer_bytes_dim, DEFAULT_CPU_FOR_EACH_BUFFER, true, ppm_sc, tp_set);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void sinsp::open_gvisor(const std::string& config_path, const std::string& root_
set_get_procs_cpu_from_driver(false);
}

void sinsp::open_modern_bpf(unsigned long driver_buffer_bytes_dim, const std::unordered_set<uint32_t> &ppm_sc_of_interest, const std::unordered_set<uint32_t> &tp_of_interest)
void sinsp::open_modern_bpf(unsigned long driver_buffer_bytes_dim, uint16_t cpus_for_each_buffer, bool online_only, const std::unordered_set<uint32_t> &ppm_sc_of_interest, const std::unordered_set<uint32_t> &tp_of_interest)
{
scap_open_args oargs = factory_open_args(MODERN_BPF_ENGINE, SCAP_MODE_LIVE);

Expand All @@ -617,6 +617,8 @@ void sinsp::open_modern_bpf(unsigned long driver_buffer_bytes_dim, const std::un
/* Engine-specific args. */
struct scap_modern_bpf_engine_params params;
params.buffer_bytes_dim = driver_buffer_bytes_dim;
params.cpus_for_each_buffer = cpus_for_each_buffer;
params.allocate_online_only = online_only;
oargs.engine_params = &params;
open_common(&oargs);
}
Expand Down
6 changes: 5 additions & 1 deletion userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
virtual void open_savefile(const std::string &filename, int fd = 0);
virtual void open_plugin(const std::string &plugin_name, const std::string &plugin_open_params);
virtual void open_gvisor(const std::string &config_path, const std::string &root_path);
virtual void open_modern_bpf(unsigned long driver_buffer_bytes_dim = DEFAULT_DRIVER_BUFFER_BYTES_DIM, const std::unordered_set<uint32_t> &ppm_sc_of_interest = {}, const std::unordered_set<uint32_t> &tp_of_interest = {});
/*[EXPERIMENTAL] This API could change between releases, we are trying to find the right configuration to deploy the modern bpf probe:
* `cpus_for_each_buffer` and `online_only` are the 2 experimental params. The first one allows associating more than one CPU to a single ring buffer.
* The last one allows allocating ring buffers only for online CPUs and not for all system-available CPUs.
*/
virtual void open_modern_bpf(unsigned long driver_buffer_bytes_dim = DEFAULT_DRIVER_BUFFER_BYTES_DIM, uint16_t cpus_for_each_buffer = DEFAULT_CPU_FOR_EACH_BUFFER, bool online_only = true, const std::unordered_set<uint32_t> &ppm_sc_of_interest = {}, const std::unordered_set<uint32_t> &tp_of_interest = {});
virtual void open_test_input(scap_test_input_data *data);

scap_open_args factory_open_args(const char* engine_name, scap_mode_t scap_mode);
Expand Down

0 comments on commit 43b33a9

Please sign in to comment.