Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions shared/bpf/skb_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ static try_inline int probe_parse_ip(void *ip, parse_ctx_t *ctx)
return -1;
}

static __always_inline u8 sk_get_protocol(struct sock *sk)
{
u32 flags = _(((u32 *)(&sk->__sk_flags_offset))[0]);
u8 l4_proto;

#ifdef CONFIG_CPU_BIG_ENDIAN
l4_proto = (flags << 8) >> 24;
#else
l4_proto = (flags << 16) >> 24;
#endif
return l4_proto;
}

static try_inline int __probe_parse_sk(parse_ctx_t *ctx)
{
struct inet_connection_sock *icsk;
Expand Down Expand Up @@ -354,15 +367,17 @@ static try_inline int __probe_parse_sk(parse_ctx_t *ctx)
if (FILTER_CHECK(ctx, l3_proto, l3_proto))
goto err;

#ifdef COMPAT_MODE
#ifdef BPF_FEAT_SK_PRPTOCOL_LEGACY
u32 flags = _(((u32 *)(&sk->__sk_flags_offset))[0]);
#ifdef CONFIG_CPU_BIG_ENDIAN
l4_proto = (flags << 8) >> 24;
l4_proto = sk_get_protocol(sk);
#else
l4_proto = (flags << 16) >> 24;
l4_proto = _C(sk, sk_protocol);
#endif
#else
l4_proto = _C(sk, sk_protocol);
if (bpf_core_field_size(sk->sk_protocol) == 2)
l4_proto = _C(sk, sk_protocol);
else
l4_proto = sk_get_protocol(sk);
#endif

if (l4_proto == IPPROTO_IP)
Expand Down
18 changes: 9 additions & 9 deletions shared/bpf/vmlinux_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -8018,16 +8018,16 @@ struct sock {
unsigned int sk_gso_max_size;
gfp_t sk_allocation;
__u32 sk_txhash;
unsigned int __sk_flags_offset[0];
unsigned int sk_padding: 1;
unsigned int sk_kern_sock: 1;
unsigned int sk_no_check_tx: 1;
unsigned int sk_no_check_rx: 1;
unsigned int sk_userlocks: 4;
unsigned int sk_protocol: 8;
unsigned int sk_type: 16;
u16 sk_gso_max_segs;
unsigned int __sk_flags_offset[0];
u8 sk_padding: 1;
u8 sk_kern_sock: 1;
u8 sk_no_check_tx: 1;
u8 sk_no_check_rx: 1;
u8 sk_userlocks: 4;
u8 sk_pacing_shift;
u16 sk_type;
u16 sk_protocol;
u16 sk_gso_max_segs;
long unsigned int sk_lingertime;
struct proto *sk_prot_creator;
rwlock_t sk_callback_lock;
Expand Down
1 change: 1 addition & 0 deletions shared/bpf/vmlinux_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -8733,6 +8733,7 @@ struct sock {
unsigned int sk_gso_max_size;
gfp_t sk_allocation;
__u32 sk_txhash;
unsigned int __sk_flags_offset[0];
u8 sk_padding: 1;
u8 sk_kern_sock: 1;
u8 sk_no_check_tx: 1;
Expand Down