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

Path resolution improvements #90

Merged
merged 8 commits into from
Jun 7, 2022
Merged

Path resolution improvements #90

merged 8 commits into from
Jun 7, 2022

Conversation

tpapagian
Copy link
Member

@tpapagian tpapagian commented May 27, 2022

This approach is based on d_path kernel function (https://elixir.bootlin.com/linux/v5.10/source/fs/d_path.c#L262).

The main difference is that we get the path in the correct order inside the kernel and thus we can do path filtering inside the kernel a bit more easier. We also removed all assembly code from path resolution. This makes the code easier to understand and maintain.

Regarding the limitations the main differences compared to d_path (and bpf_d_path) is that we should have a finite number of iterations and the error handling is not as complete as in the kernel. The advantage is that we can use that in older kernels as well (tested for >= 4.19).

Regarding the limitation on the path components:

before:

  1. Up to 2 mount point with 11 path components each of them (kernels <= 5.3)
  2. Up to 32 mount points and 32 path components for each of them (kernels > 5.4)

now:

  1. Up to 11 path components independently of mount points (i.e. we can have from 1 up to 10 mount points) (kernels <= 5.3)
  2. Up to 128 path components independently of mount points (kernels > 5.4)

Signed-off-by: Anastasios Papagiannis tasos.papagiannnis@gmail.com

@tpapagian tpapagian force-pushed the pr/apapag/path_resolution branch 9 times, most recently from 2d67b7a to 86b7533 Compare June 1, 2022 07:45
@tpapagian tpapagian changed the title Change the approach to do path resolution in ebpf Path resolution improvements Jun 1, 2022
@tpapagian tpapagian marked this pull request as ready for review June 1, 2022 12:52
@tpapagian tpapagian requested a review from a team as a code owner June 1, 2022 12:52
@tpapagian tpapagian requested a review from jrfastab June 1, 2022 12:52
"r3 = *(u64 *)%[symbol];\n" \
"call 4;\n" CWD_OFFSET_REG " += 1;\n"

#define MARK_UNRESOLVED_PATH_IF_NEEDED \
Copy link
Contributor

Choose a reason for hiding this comment

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

hurray slowly but surely deleting all my asm hacks.

go test -gcflags="" -c ./pkg/metrics         -o go-tests/metrics.test
?   	github.com/cilium/tetragon/pkg/metrics	[no test files]

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
This commit introduces __d_path_local function that is mainly based
on d_path kernel function (https://elixir.bootlin.com/linux/v5.10/source/fs/d_path.c#L262).

The main difference is that we get the path in the correct order inside the kernel
and thus we can do path filtering inside the kernel a bit more easier. We also
removed all assembly code from path resolution. This makes the code easier to
understand and maintain.

Regarding the limitations the main differences compared to d_path (and bpf_d_path)
is that we should have a finite number of iterations and the error handling is not
as complete as in the kernel. The advantage is that we can use that in older kernels
as well (tested for >= 4.19).

Regarding the limitation on the path components:

before:
1. Up to 2 mount point with 11 path components each of them (kernels <= 5.3)
2. Up to 32 mount points and 32 path components for each of them (kernels > 5.4)

now::
1. Up to 11 path components independently of mount points (i.e. we can have from 1 up to 10 mount points)  (kernels <= 5.3)
2. Up to 128 path components independently of mount points (kernels > 5.4)

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
This commit also includes the required changes in the user space
(i.e. not reversing the path).

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
This commit also includes the required changes in the user space
(i.e. not reversing the path).

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
The new approach allows us to do so.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
The increase in path components and mount point limits requires also
changes in the tests.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
Now we have only limitations due to path components not mount
points. So remove all of this code.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
@jrfastab jrfastab merged commit eff35ad into main Jun 7, 2022
@jrfastab jrfastab deleted the pr/apapag/path_resolution branch June 7, 2022 03:50
tpapagian added a commit that referenced this pull request Jun 23, 2022
Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jun 23, 2022
Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
kkourt pushed a commit that referenced this pull request Jun 28, 2022
Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 14, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 15, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 15, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 15, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 18, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 21, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 21, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 21, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
tpapagian added a commit that referenced this pull request Jul 22, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
kkourt pushed a commit that referenced this pull request Jul 22, 2022
The previous commit (c0a16b3) shows that there is a bug in
TestKprobeMatchArgsFilePrefix unit test and more specifically
in the case of Prefix operator.

Most possibly this bug was introduced in #90.

This commit fixes this issue.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants