Skip to content

Only attempt to probe ipv6 if present #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions bpf_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,17 @@ bpf_queue_open1(struct quark_queue *qq, int use_fentry)
if (use_fentry) {
bpf_program__set_autoload(p->progs.fexit__inet_csk_accept, 1);
bpf_program__set_autoload(p->progs.fexit__tcp_v4_connect, 1);
bpf_program__set_autoload(p->progs.fexit__tcp_v6_connect, 1);
if (ipv6_supported())
bpf_program__set_autoload(p->progs.fexit__tcp_v6_connect, 1);
bpf_program__set_autoload(p->progs.fentry__tcp_close, 1);
} else {
bpf_program__set_autoload(p->progs.kretprobe__inet_csk_accept, 1);
bpf_program__set_autoload(p->progs.kprobe__tcp_v4_connect, 1);
bpf_program__set_autoload(p->progs.kretprobe__tcp_v4_connect, 1);
bpf_program__set_autoload(p->progs.kprobe__tcp_v6_connect, 1);
bpf_program__set_autoload(p->progs.kretprobe__tcp_v6_connect, 1);
if (ipv6_supported()) {
bpf_program__set_autoload(p->progs.kprobe__tcp_v6_connect, 1);
bpf_program__set_autoload(p->progs.kretprobe__tcp_v6_connect, 1);
}
bpf_program__set_autoload(p->progs.kprobe__tcp_close, 1);
}

Expand Down
8 changes: 5 additions & 3 deletions quark.c
Original file line number Diff line number Diff line change
Expand Up @@ -2065,9 +2065,11 @@ sproc_scrape(struct quark_queue *qq)
r = sproc_net_tcp(qq, AF_INET, &socket_tmp_tree);
if (r == -1)
goto done;
r = sproc_net_tcp(qq, AF_INET6, &socket_tmp_tree);
if (r == -1)
goto done;
if (ipv6_supported()) {
r = sproc_net_tcp(qq, AF_INET6, &socket_tmp_tree);
if (r == -1)
goto done;
}

by_inode = &socket_tmp_tree;
}
Expand Down
1 change: 1 addition & 0 deletions quark.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ int strtou64(u64 *, const char *, int);
char *find_line(FILE *, const char *);
char *find_line_p(const char *, const char *);
char *load_file_nostat(int, size_t *);
int ipv6_supported(void);

enum quark_verbosity_levels {
QUARK_VL_SILENT,
Expand Down
14 changes: 14 additions & 0 deletions qutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ load_file_nostat(int fd, size_t *total)
return (buf);
}

int
ipv6_supported(void)
{
int fd;
int enabled = 0;

if ((fd = socket(AF_INET6, SOCK_STREAM, 0)) != -1) {
enabled = 1;
close(fd);
}

return enabled;
}

void
qlog_func(int pri, int do_errno, const char *func, int lineno,
const char *fmt, ...)
Expand Down