Skip to content

Commit

Permalink
refactor(libsinsp_e2e): address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Apr 12, 2024
1 parent 03835ed commit 34371e1
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions driver/modern_bpf/helpers/store/auxmap_store_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -1378,27 +1378,18 @@ static __always_inline void apply_dynamic_snaplen(struct pt_regs *regs, uint16_t

if(port_remote == 0 && sockaddr != NULL)
{
BPF_CORE_READ_USER_INTO(&socket_family, (struct sockaddr*)sockaddr, sa_family);

// If socket_family is 0 we skip this part.
switch(socket_family)
if(socket_family == AF_INET)
{
struct sockaddr_in sockaddr_in = {};
bpf_probe_read_user(&sockaddr_in, bpf_core_type_size(struct sockaddr_in), sockaddr);
port_remote = ntohs(sockaddr_in.sin_port);
}
else
{
case AF_INET:
{
struct sockaddr_in sockaddr_in = {};
bpf_probe_read_user(&sockaddr_in, bpf_core_type_size(struct sockaddr_in), sockaddr);
port_remote = ntohs(sockaddr_in.sin_port);
break;
}
case AF_INET6:
{
struct sockaddr_in6 sockaddr_in6 = {};
bpf_probe_read_user(&sockaddr_in6, bpf_core_type_size(struct sockaddr_in6), sockaddr);
port_remote = ntohs(sockaddr_in6.sin6_port);
break;
}
default:
break;
struct sockaddr_in6 sockaddr_in6 = {};
bpf_probe_read_user(&sockaddr_in6, bpf_core_type_size(struct sockaddr_in6), sockaddr);
port_remote = ntohs(sockaddr_in6.sin6_port);
}
}
}
Expand Down

0 comments on commit 34371e1

Please sign in to comment.