Skip to content
Merged
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
14 changes: 9 additions & 5 deletions tools/tcpconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
{
__u64 pid_tgid = bpf_get_current_pid_tgid();
struct sock *sk = (struct sock *)PT_REGS_PARM1(ctx);
struct inet_sock *is = inet_sk(sk);
struct inet_sock *is = (struct inet_sock *)sk;

// only grab port 53 packets, 13568 is ntohs(53)
if (is->inet_dport == 13568) {
Expand All @@ -303,7 +303,7 @@
goto delete_and_return;
size_t buflen = (size_t)copied;

if (buflen > msghdr->msg_iter.iov->iov_len)
if (buflen > msghdr->msg_iter.IOV_FIELD->iov_len)
goto delete_and_return;

if (buflen > MAX_PKT)
Expand All @@ -313,7 +313,7 @@
if (!data) // this should never happen, just making the verifier happy
return 0;

void *iovbase = msghdr->msg_iter.iov->iov_base;
void *iovbase = msghdr->msg_iter.IOV_FIELD->iov_base;
bpf_probe_read(data->pkt, buflen, iovbase);
dns_events.perf_submit(ctx, data, buflen);

Expand Down Expand Up @@ -386,10 +386,14 @@
bpf_text = bpf_text.replace('FILTER_UID', '')

if args.dns:
if BPF.kernel_struct_has_field(b'iov_iter', b'iter_type') == 1:
if BPF.kernel_struct_has_field(b'iov_iter', b'type') == 1:
dns_bpf_text = dns_bpf_text.replace('TYPE_FIELD', 'type')
else:
dns_bpf_text = dns_bpf_text.replace('TYPE_FIELD', 'iter_type')
if BPF.kernel_struct_has_field(b'iov_iter', b'iov') == 1:
dns_bpf_text = dns_bpf_text.replace('IOV_FIELD', 'iov')
else:
dns_bpf_text = dns_bpf_text.replace('TYPE_FIELD', 'type')
dns_bpf_text = dns_bpf_text.replace('IOV_FIELD', '__iov')
bpf_text += dns_bpf_text

if debug or args.ebpf:
Expand Down
Loading