Re: [RFC PATCH net-next 1/3] selftests/bpf: Move rxq_num helper from xdp_hw_metadata to network_helpers

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

 



YiFei Zhu wrote:
> This helper may be useful for other AF_XDP tests, such as xsk_hw.
> Moving it out so we don't need to copy-paste that function.
> 
> I also changed the function from directly calling error(1, errno, ...)
> to returning an error because I don't think it makes sense for a
> library function to outright kill the process if the function fails.
> 
> Signed-off-by: YiFei Zhu <zhuyifei@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/network_helpers.c | 27 +++++++++++++++++++
>  tools/testing/selftests/bpf/network_helpers.h |  2 ++
>  tools/testing/selftests/bpf/xdp_hw_metadata.c | 27 ++-----------------
>  3 files changed, 31 insertions(+), 25 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 35250e6cde7f..4c3bef07df23 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c
> @@ -569,6 +569,33 @@ int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
>  	return 0;
>  }
>  
> +int rxq_num(const char *ifname)
> +{
> +	struct ethtool_channels ch = {
> +		.cmd = ETHTOOL_GCHANNELS,
> +	};
> +	struct ifreq ifr = {
> +		.ifr_data = (void *)&ch,
> +	};
> +	strncpy(ifr.ifr_name, ifname, IF_NAMESIZE - 1);
> +	int fd, ret, err;

Since sending this as RFC, when sending for inclusion let's move the
strncpy, to not mix declarations and code.




[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