Skip to content

Commit

Permalink
samples: bpf: force IPv4 in ping
Browse files Browse the repository at this point in the history
ping localhost may default of IPv6 on modern systems, but
samples are trying to only parse IPv4.  Force IPv4.

samples/bpf/tracex1_user.c doesn't interpret the packet so
we don't care which IP version will be used there.

Signed-off-by: Jakub Kicinski <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
Jakub Kicinski authored and borkmann committed Feb 28, 2019
1 parent ebace0e commit 5c3cf87
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion samples/bpf/sock_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(void)
{
FILE *f;

f = popen("ping -c5 localhost", "r");
f = popen("ping -4 -c5 localhost", "r");
(void)f;

return test_sock();
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex1_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(int ac, char **argv)
assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd,
sizeof(prog_fd[0])) == 0);

f = popen("ping -c5 localhost", "r");
f = popen("ping -4 -c5 localhost", "r");
(void) f;

for (i = 0; i < 5; i++) {
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex2_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main(int ac, char **argv)
assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd,
sizeof(prog_fd[0])) == 0);

f = popen("ping -c5 localhost", "r");
f = popen("ping -4 -c5 localhost", "r");
(void) f;

for (i = 0; i < 5; i++) {
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex3_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(int argc, char **argv)
sizeof(__u32)) == 0);

if (argc > 1)
f = popen("ping -c5 localhost", "r");
f = popen("ping -4 -c5 localhost", "r");
else
f = popen("netperf -l 4 localhost", "r");
(void) f;
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tracex2_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int main(int ac, char **argv)
signal(SIGTERM, int_exit);

/* start 'ping' in the background to have some kfree_skb events */
f = popen("ping -c5 localhost", "r");
f = popen("ping -4 -c5 localhost", "r");
(void) f;

/* start 'dd' in the background to have plenty of 'write' syscalls */
Expand Down

0 comments on commit 5c3cf87

Please sign in to comment.