Skip to content

Commit 0bac72d

Browse files
[#105]: fixed pid parameter extraction in kernel space
1 parent 9a115b9 commit 0bac72d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/src/components/conntracker/src/data_structures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct PacketLog {
88
pub src_port: u16,
99
pub dst_ip: u32,
1010
pub dst_port: u16,
11-
pub pid: u64,
11+
pub pid: u32
1212
}
1313

1414
// This structure is only for active connections

core/src/components/conntracker/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub fn try_veth_tracer(ctx: ProbeContext, mode: u8) -> Result<u32, i64> {
191191
read_linux_inner_value::<[u32; 8]>(net_device_pointer as *const u8, dev_addr_offset)?;
192192

193193
let inum: u32 = extract_netns_inum(net_device_pointer as *const u8)?;
194-
let pid: u32 = (bpf_get_current_pid_tgid() << 32) as u32; //extracting lower 32 bit corresponding to the PID
194+
let pid: u32 = bpf_get_current_pid_tgid() as u32; //extracting lower 32 bit corresponding to the PID
195195

196196
//buffer copying for array types
197197
name_buf.copy_from_slice(&name_array);
@@ -249,7 +249,7 @@ fn try_identity_classifier(ctx: TcContext) -> Result<(), i64> {
249249
); //14+IHL-Lenght+0
250250
let proto = u8::from_be(ctx.load::<u8>(PROTOCOL_T0TAL_BYTES_OFFSET).map_err(|_| 1)?);
251251

252-
let pid = bpf_get_current_pid_tgid() & 0xFFFFFFFF;
252+
let pid: u32 = bpf_get_current_pid_tgid() as u32;
253253

254254
//not logging internal communication packets
255255
//TODO: do not log internal communications such as minikube dashboard packets or kubectl api packets

0 commit comments

Comments
 (0)