Get correct PID in TCPSendStack example
authorTeng Qin <qinteng@fb.com>
Sun, 21 May 2017 05:44:32 +0000 (22:44 -0700)
committerTeng Qin <qinteng@fb.com>
Sun, 21 May 2017 05:44:32 +0000 (22:44 -0700)
examples/cpp/TCPSendStack.cc

index 84f0e5f..fd0b68d 100644 (file)
@@ -32,7 +32,7 @@ BPF_HASH(counts, struct stack_key_t, uint64_t);
 
 int on_tcp_send(struct pt_regs *ctx) {
   struct stack_key_t key = {};
-  key.pid = bpf_get_current_pid_tgid();
+  key.pid = bpf_get_current_pid_tgid() >> 32;
   bpf_get_current_comm(&key.name, sizeof(key.name));
   key.kernel_stack = stack_traces.get_stackid(ctx, BPF_F_REUSE_STACKID);
   key.user_stack = stack_traces.get_stackid(