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

socket enricher: add new fields: ppid, pcomm, exepath, cwd #2683

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alban
Copy link
Member

@alban alban commented Apr 4, 2024

This patch adds new fields in the socket enricher. It is not used by any gadget yet, but it makes it possible to add the new fields in gadgets using the socket enricher.

How to use

If you want to make use of the new fields in your own gadget, you could write something like:

--- a/pkg/gadgets/trace/dns/tracer/bpf/dns.c
+++ b/pkg/gadgets/trace/dns/tracer/bpf/dns.c
@@ -234,8 +234,11 @@ int ig_trace_dns(struct __sk_buff *skb)
                event.mount_ns_id = skb_val->mntns;
                event.pid = skb_val->pid_tgid >> 32;
                event.tid = (__u32)skb_val->pid_tgid;
+               event.ppid = skb_val->ppid;
                __builtin_memcpy(&event.task, skb_val->task,
                                 sizeof(event.task));
+               __builtin_memcpy(&event.pcomm, skb_val->pcomm,
+                                sizeof(event.pcomm));
                event.uid = (__u32)skb_val->uid_gid;
                event.gid = (__u32)(skb_val->uid_gid >> 32);
        }

See PR #2684 for an example in the dns gadget.

Testing done

Let's check the CI.

Copy link
Member Author

@alban alban left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Gadget benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: a38b673 Previous: ad488f3 Ratio
BenchmarkAllGadgetsWithContainers/container0/trace-dns 26879440 ns/op 8837005 ns/op 3.04
BenchmarkAllGadgetsWithContainers/container0/trace-network 19798211 ns/op 2265452 ns/op 8.74

This comment was automatically generated by workflow using github-action-benchmark.

CC: @alban

This patch adds new fields in the socket enricher. It is not used by any
gadget yet, but it makes it possible to add the new fields in gadgets
using the socket enricher.

Signed-off-by: Alban Crequy <albancrequy@linux.microsoft.com>
@alban alban force-pushed the alban_socket_enricher_more_fields1 branch from 5eef1f9 to a38b673 Compare May 3, 2024 17:24
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.

None yet

1 participant