Re: [PATCH bpf-next v9 4/5] selftests/bpf: Move open_netns() and close_netns() into network_helpers.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 06, 2022 at 11:34:03PM +0100, Toke Høiland-Jørgensen wrote:
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 6db1af8fdee7..2bb1f9b3841d 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c
> @@ -1,18 +1,25 @@
>  // SPDX-License-Identifier: GPL-2.0-only
> +#define _GNU_SOURCE
> +
>  #include <errno.h>
>  #include <stdbool.h>
>  #include <stdio.h>
>  #include <string.h>
>  #include <unistd.h>
> +#include <sched.h>
sched.h is added.

[ ... ]

> diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h
> index d198181a5648..a4b3b2f9877b 100644
> --- a/tools/testing/selftests/bpf/network_helpers.h
> +++ b/tools/testing/selftests/bpf/network_helpers.h
> @@ -55,4 +55,13 @@ int make_sockaddr(int family, const char *addr_str, __u16 port,
>  		  struct sockaddr_storage *addr, socklen_t *len);
>  char *ping_command(int family);
>  
> +struct nstoken;
> +/**
> + * open_netns() - Switch to specified network namespace by name.
> + *
> + * Returns token with which to restore the original namespace
> + * using close_netns().
> + */
> +struct nstoken *open_netns(const char *name);
> +void close_netns(struct nstoken *token);
>  #endif
> diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> index 2b255e28ed26..d9e48b3ac9a6 100644
> --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> @@ -22,7 +22,6 @@
>  #include <sched.h>
sched.h can be removed?

and the _GNU_SOURCE above.

>  #include <stdbool.h>
>  #include <stdio.h>
> -#include <sys/mount.h>
>  #include <sys/stat.h>
>  #include <unistd.h>


Others lgtm.

Acked-by: Martin KaFai Lau <kafai@xxxxxx>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux