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

[3/n] new(libscap): platform abstraction support: clean up scap_init_*_int #1042

Merged
merged 12 commits into from
Jul 14, 2023

Conversation

gnosek
Copy link
Contributor

@gnosek gnosek commented Apr 11, 2023

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap-engine-udig

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:

After the giant buildup of #1040 and #1041, this puts the cherry on top and unifies all the scap_init_*_int into one.

Special notes for your reviewer:

This PR is huge since it contains #1040 and #1041 inside. It will get manageable after they're done.

Does this PR introduce a user-facing change?:

NONE

@poiana poiana requested a review from hbrueckner April 11, 2023 14:34
@poiana poiana requested a review from LucaGuerra April 11, 2023 14:34
@gnosek gnosek changed the title [2/n] new(libscap): platform abstraction support: clean up scap_init_*_int [3/n] new(libscap): platform abstraction support: clean up scap_init_*_int Apr 11, 2023
@gnosek gnosek changed the title [3/n] new(libscap): platform abstraction support: clean up scap_init_*_int wip: [3/n] new(libscap): platform abstraction support: clean up scap_init_*_int Apr 11, 2023
@FedeDP
Copy link
Contributor

FedeDP commented Apr 17, 2023

/milestone 0.12.0

@poiana poiana added this to the 0.12.0 milestone Apr 17, 2023
@leogr leogr modified the milestones: 0.12.0, 0.13.0 May 3, 2023
@leogr leogr modified the milestones: 0.13.0, 0.12.0 May 10, 2023
@Andreagit97 Andreagit97 modified the milestones: 0.12.0, libs-backlog Jun 7, 2023
@gnosek gnosek force-pushed the platform3 branch 4 times, most recently from 25ecef1 to c2ed438 Compare June 20, 2023 11:23
@gnosek gnosek force-pushed the platform3 branch 4 times, most recently from aecbf47 to 0d82297 Compare June 23, 2023 16:44
@FedeDP
Copy link
Contributor

FedeDP commented Jul 5, 2023

/milestone 0.12.0
This should be a tiny patch on top of #1171 therefore we should go with it too. Same applies to #1170 .

gnosek added 12 commits July 13, 2023 16:27
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
We are about to use the checks for all engines (if they don't
support API versions, the check will be a no-op) so we cannot
provide the functions in a Linux-only library.

Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
@gnosek gnosek changed the title wip: [3/n] new(libscap): platform abstraction support: clean up scap_init_*_int [3/n] new(libscap): platform abstraction support: clean up scap_init_*_int Jul 13, 2023
Copy link
Contributor

@incertum incertum left a comment

Choose a reason for hiding this comment

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

Agree it's a tiny patch on top we should merge ASAP for consistency.

/approve

Just had a general question I am noticing just now and if we want to address it, it needs to be a separate PR anyways:

For the plugin use case we have platform = scap_generic_alloc_platform(); where .init_platform is NULL in that vtable. However for the Falco metrics use case we rely on lookups part of scap_linux_init_platform (host boot ts or gethostname, num_cpus ...) and then also scap_linux_retrieve_agent_info for fetching the start_time for CPU usage calculation in sinsp resource utilization module.

And then @jasondellaluce would know better re the aspect of plugins now exposing syscalls event source and we have more extensions planned, so I was curious as to why HAS_ENGINE_SOURCE_PLUGIN doesn't get a linux platform as well while understanding that for some cases we don't need the proc scan etc. Ideas how to consolidate all these use cases @gnosek?

And then just some naming nits struct scap_platform_vtable scap_generic_platform_vtable but static const struct scap_platform_vtable scap_linux_platform could also add a _vtable suffix for clarity. But again this is not about the changes in this PR.

@poiana
Copy link
Contributor

poiana commented Jul 13, 2023

LGTM label has been added.

Git tree hash: 077706412b35f03dfb1ca084745788aa52f60d3c

@gnosek
Copy link
Contributor Author

gnosek commented Jul 13, 2023

Agree it's a tiny patch on top we should merge ASAP for consistency.

/approve

<3

Just had a general question I am noticing just now and if we want to address it, it needs to be a separate PR anyways:

For the plugin use case we have platform = scap_generic_alloc_platform(); where .init_platform is NULL in that vtable. However for the Falco metrics use case we rely on lookups part of scap_linux_init_platform (host boot ts or gethostname, num_cpus ...) and then also scap_linux_retrieve_agent_info for fetching the start_time for CPU usage calculation in sinsp resource utilization module.

So I suppose we can move machine_info and agent_info into the generic platform, but then it will have to compile everywhere (obviously doable), and this will have to go in in 0.12 too, to avoid breaking your use case. I'll see what I can do :)

And then @jasondellaluce would know better re the aspect of plugins now exposing syscalls event source and we have more extensions planned, so I was curious as to why HAS_ENGINE_SOURCE_PLUGIN doesn't get a linux platform as well while understanding that for some cases we don't need the proc scan etc. Ideas how to consolidate all these use cases @gnosek?

Short term: add a flag like for the test_input engine to let you choose between generic and linux platforms (I'd expect many source plugins won't care about processes or network interfaces so we shouldn't make them pay the cost).

Long term: just open whatever platform you wish, it's going to be independent from the engine anyway.

Currently (as of 4/n) there shouldn't be any places where a specific engine is tied to a specific platform, except for scap_init and friends that tie engines and platforms together, so it's "only" a matter of exposing a usable API. You probably won't want to use the savefile platform for the gvisor engine :D but apart from the top-level API, nothing prevents you from using e.g. an all new and improved platform with an existing engine or vice versa.

And then just some naming nits struct scap_platform_vtable scap_generic_platform_vtable but static const struct scap_platform_vtable scap_linux_platform could also add a _vtable suffix for clarity. But again this is not about the changes in this PR.

Oops :) my excuse is that scap_linux_platform isn't visible outside the file it's defined in but you're right, I should clean that up. Now let's bikeshed whether we want to add _vtable or remove it :)

@incertum
Copy link
Contributor

Thanks @gnosek I'll be available to review the PR around the minor extension for the plugins case. re the other question I directed also to Jason I am not yet too knowledgeable about the plugins and they are still evolving, so just wanted to highlight that we should all double check where we are heading wrt to plugins. re the naming, it's really not too important rn.

Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Jul 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, gnosek, incertum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [FedeDP,gnosek,incertum]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit d2ac5fc into falcosecurity:master Jul 14, 2023
17 checks passed
@gnosek gnosek deleted the platform3 branch July 14, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants