From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0328B1DDA09 for ; Tue, 28 Jan 2025 23:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738105248; cv=none; b=kU/CefLDxQFtlNzS2MQOtvXwPFQruzLvWV5EyVv33C05yYYXtKbe2+J4+5LjK3yx476i5WDgciI5/DpARiz2GuZVHhbtGM10bgLlnKhjsgTe4YRX68nyjw/Xw+GkpfGdlloB/WPGvB6IXI19HD5UnKT3zibWAdXK228rA+oHFEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738105248; c=relaxed/simple; bh=chm2ypBwThzpaL84x7U9Nnr9yzQ9rB4wBZ7jwetLeJA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LeO0uVuLyQxe5+/x/sjQJdlech+19AJAgszr1rJihC/1Lvo1OLarN6lKFh1+RXU6algzlqy5ckAZAymkbdVvppzdkLFMQdeXNFYsPn6rMZ4JUg7fU7hMz6VCForuroiYj2vZYyyONIDJqa7JV97OrjGOz0VT1H1icHGQcvVyYkk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=A9qMvB01; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="A9qMvB01" Message-ID: <3a499ffe-0514-49bf-8022-06a9b713b920@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1738105235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TxQEaHtAioWTOPE03cWnnU3Ly/20naE0Cm9ju2UfWJQ=; b=A9qMvB01qCeiCa/T4G25MGdbBz2f54lHVjQarpqlOtEXnURllkJWwJ59l40LYSRsJ4roE7 Ta/eFhjXYhdjq36qPqvgqvUFG6JMV2TE6xGhr2wGdvY/q92gmdsIbQI0G6CoybzzkJTYwn tmKC4hWbPJxeueIdOENw0FbE0ZrxFEI= Date: Tue, 28 Jan 2025 15:00:26 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v3 09/14] selftests/bpf: test_xdp_veth: Use unique names To: "Bastien Curutchet (eBPF Foundation)" Cc: Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Alexis Lothore , Thomas Petazzoni , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250128-redirect-multi-v3-0-c1ce69997c01@bootlin.com> <20250128-redirect-multi-v3-9-c1ce69997c01@bootlin.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20250128-redirect-multi-v3-9-c1ce69997c01@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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; > }