Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples: bpf: force IPv4 in ping

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 <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Jakub Kicinski and committed by
Daniel Borkmann
5c3cf87d ebace0e9

+5 -5
+1 -1
samples/bpf/sock_example.c
··· 99 99 { 100 100 FILE *f; 101 101 102 - f = popen("ping -c5 localhost", "r"); 102 + f = popen("ping -4 -c5 localhost", "r"); 103 103 (void)f; 104 104 105 105 return test_sock();
+1 -1
samples/bpf/sockex1_user.c
··· 26 26 assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd, 27 27 sizeof(prog_fd[0])) == 0); 28 28 29 - f = popen("ping -c5 localhost", "r"); 29 + f = popen("ping -4 -c5 localhost", "r"); 30 30 (void) f; 31 31 32 32 for (i = 0; i < 5; i++) {
+1 -1
samples/bpf/sockex2_user.c
··· 34 34 assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd, 35 35 sizeof(prog_fd[0])) == 0); 36 36 37 - f = popen("ping -c5 localhost", "r"); 37 + f = popen("ping -4 -c5 localhost", "r"); 38 38 (void) f; 39 39 40 40 for (i = 0; i < 5; i++) {
+1 -1
samples/bpf/sockex3_user.c
··· 58 58 sizeof(__u32)) == 0); 59 59 60 60 if (argc > 1) 61 - f = popen("ping -c5 localhost", "r"); 61 + f = popen("ping -4 -c5 localhost", "r"); 62 62 else 63 63 f = popen("netperf -l 4 localhost", "r"); 64 64 (void) f;
+1 -1
samples/bpf/tracex2_user.c
··· 131 131 signal(SIGTERM, int_exit); 132 132 133 133 /* start 'ping' in the background to have some kfree_skb events */ 134 - f = popen("ping -c5 localhost", "r"); 134 + f = popen("ping -4 -c5 localhost", "r"); 135 135 (void) f; 136 136 137 137 /* start 'dd' in the background to have plenty of 'write' syscalls */