lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a499ffe-0514-49bf-8022-06a9b713b920@linux.dev>
Date: Tue, 28 Jan 2025 15:00:26 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@...tlin.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>, "David S. Miller"
 <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
 Jesper Dangaard Brouer <hawk@...nel.org>,
 John Fastabend <john.fastabend@...il.com>,
 Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>,
 Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
 KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
 Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
 Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
 Alexis Lothore <alexis.lothore@...tlin.com>,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
 bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v3 09/14] selftests/bpf: test_xdp_veth: Use
 unique names

On 1/28/25 1:57 AM, Bastien Curutchet (eBPF Foundation) wrote:
> +#define NO_IP				"NO_IP"
>   #define PROG_NAME_MAX_LEN	128
> +#define NS_NAME_MAX_LEN		32
>   
>   struct veth_configuration {
>   	char local_veth[VETH_NAME_MAX_LEN]; /* Interface in main namespace */
>   	char remote_veth[VETH_NAME_MAX_LEN]; /* Peer interface in dedicated namespace*/
> -	const char *namespace; /* Namespace for the remote veth */
> +	char namespace[NS_NAME_MAX_LEN]; /* Namespace for the remote veth */
>   	int next_veth; /* Local interface to redirect traffic to */
> -	char *remote_addr; /* IP address of the remote veth */
> +	char remote_addr[IP_MAX_LEN]; /* IP address of the remote veth */
>   };
>   

>   	{
> -		.local_veth = "veth2",
> +		.local_veth = "veth2-",
>   		.remote_veth = "veth22",
>   		.next_veth = 2,
> -		.remote_addr = NULL,
> -		.namespace = "ns-veth22"
> +		.remote_addr = NO_IP,
> +		.namespace = "ns-veth22-"
>   	},

> -static int create_network(void)
> +static int create_network(struct veth_configuration *net_config)
>   {
> -	int i;
> +	int i, err;
> +
> +	memcpy(net_config, default_config, VETH_PAIRS_COUNT * sizeof(struct veth_configuration));
>   
>   	/* First create and configure all interfaces */
>   	for (i = 0; i < VETH_PAIRS_COUNT; i++) {
> +		err = append_tid(net_config[i].namespace, strlen(net_config[i].namespace));
> +		if (!ASSERT_OK(err, "append TID to ns name"))
> +			return -1;
> +
> +		err = append_tid(net_config[i].local_veth, strlen(net_config[i].local_veth));
> +		if (!ASSERT_OK(err, "append TID to local veth name"))
> +			return -1;
> +
>   		SYS(fail, "ip netns add %s", net_config[i].namespace);
>   		SYS(fail, "ip link add %s type veth peer name %s netns %s",
>   		    net_config[i].local_veth, net_config[i].remote_veth, net_config[i].namespace);
>   		SYS(fail, "ip link set dev %s up", net_config[i].local_veth);
> -		if (net_config[i].remote_addr)
> +		if (memcmp(net_config[i].remote_addr, NO_IP, 5))

nit. May be "if (net_config[i].remote_addr[0])" instead of defining a new 
"NO_IP" and then memcmp.

>   			SYS(fail, "ip -n %s addr add %s/24 dev %s",	net_config[i].namespace,
>   			    net_config[i].remote_addr, net_config[i].remote_veth);
>   		SYS(fail, "ip -n %s link set dev %s up", net_config[i].namespace,
> @@ -155,7 +169,7 @@ static int create_network(void)
>   	return -1;
>   }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ