samples: bpf: force IPv4 in ping
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 28 Feb 2019 03:04:10 +0000 (19:04 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 28 Feb 2019 23:53:45 +0000 (00:53 +0100)
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>
samples/bpf/sock_example.c
samples/bpf/sockex1_user.c
samples/bpf/sockex2_user.c
samples/bpf/sockex3_user.c
samples/bpf/tracex2_user.c

index 60ec467..00aae1d 100644 (file)
@@ -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();
index 93ec01c..be8ba56 100644 (file)
@@ -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++) {
index 1d5c6e9..125ee6e 100644 (file)
@@ -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++) {
index 9d02e04..bbb1cd0 100644 (file)
@@ -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;
index 1a81e6a..c9544a4 100644 (file)
@@ -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 */