From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 373351684AC for ; Tue, 11 Mar 2025 06:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741673994; cv=none; b=YayVHH0xgOIBAGDJmrG5JmYka6BnKLilTXZltLkxma/YN86IxIrQFIfuxHtgUWj2q9YN/IvMokJmag0ttJWMhwQ8bk2GQKmkTZ+VZs1sOjRskjjv9R8MPztJwAQZjjdm+XJchkSoDyWOXLdPtgpN5nscaddS3CNMQhv5MgXWNsk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741673994; c=relaxed/simple; bh=ZP4EaVCBU43ETX1tsWfetopJ677SR8acZVhOJLrcrw0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Qr3MIEURdwiZ2AQ9oOTvJimJr9DymOu3Zs1cc6Ks04wgr8uf41RuiRWxesVVC21dH5Ft/zeEnxi9p+P01w+G3V8mH346ewCisfxy+kcXyT6sI/WMUwFTpzQAEA9YnF0zbhtfKOj/SpM12NGpeawXIZ3AJnIKGgYxyfZp+pk1UwA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=pass smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=r0pVdBqS; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="r0pVdBqS" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-22409077c06so2155105ad.1 for ; Mon, 10 Mar 2025 23:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1741673992; x=1742278792; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=EbcW5/eDAGhdpWi7HyX3jjOdHbLTgrUim/DP0OQGuWo=; b=r0pVdBqSlYlaLTahjdTPd8TF3QsBOiOSOqTWeNjGAMKFcI3nXQfondYE+kch38jYSL 5YwEt4prOcOBGftjrZ1F72y8/J6hrFawCMkGNOP7+u7cJYnWCiXuiIRC2SESSFSS8CHA FpBomgMo+qnJRoTHuw9co+mDt0+ce85cp3ZT6HRywW3SPQ4o/xiUA36SkNWtxvrAuT1w WQGmmF9NVuhUaZJNg8ARmVSDem38gWxRzgcUhPrBP2GNGfHzkT7cU3GnW9wdecY583rN TaB0euWxhno9HQIRt0XJG3o75zVFGnVvvndOBG4FGmbz/S++SRb1q0Bsu7843OPZgFzX zPsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741673992; x=1742278792; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EbcW5/eDAGhdpWi7HyX3jjOdHbLTgrUim/DP0OQGuWo=; b=cUeB94PYTa4aXSEapW0r9pNqOQt9XOkJpirpz3SWA2h458cclAcIG/cnhPkSzB3tF9 eTvBkd8FhR7BoJhtqZrg0JPTvVDbSsSrTtcOLOqgFnV553Qs5EItsZQrKiDTnNUZmGZn cuicStJwlIIO+/Tb5SN0Cd+B8eok0qebYbLWTdFdNmtbUKlyr+rQfrlBach4AGOjgvYT DvGT9H/vRP06mCaWHdS3oqQ6zDcDImvsTrbkc1gzeGv3fFkdPluO9j4AuIkt0HkK7euW e1ndKnSDLrGhPeEoFOnE6va0JTbjDHnORua+dihFRzk8lgRydn80wpqqLIy4CNG1qeyj 6HRw== X-Forwarded-Encrypted: i=1; AJvYcCXfWit+HApNI9IdLeW9wbG2SrD4dXc2OOPHYIeiCD8q1QNVrJvtb4OTjgPQbalqVG7UxHQaiBG1uNZuPHE=@vger.kernel.org X-Gm-Message-State: AOJu0YzehDetI9n5mM1wQaUISWR5JIJdzXljkjua7qYa2yDnwyiqmyLO iXRtXb4qqi9nl+dZfOn01q4vI4tU1ipYZ060uaXAmiHwzoKo8NS/FXJ+fVE9J5k= X-Gm-Gg: ASbGncvsQ95m20FOfe/0FUKQTshdm136uc+8o+laSqlteNbZufTNcL4vq+F8G97hfTo 7x7O6qcNglDuk1NVQF5aExWjiVHdBJfW5Z6WgfSxIW7k4YBrlL/EAmtgOvKnGxDNhe7TWTbz/IS ssuYLDdZOcHiTmulTZD3IH847AkDlNzbKTimOEpIi7cfxvr5YDdxlxyLUxYS9mBZApPdNO7zbI6 QwvFaF6RRjbv+LEyjkmVW++zc+W4ziD4hM/hxR2UtRZlkoKmptrdDEO6YXSzWkvEeZzB5gCLj7f ku7GLgibw0GH+H4YjJ3xDqzEdqgk3l72NvfM9CCJoRgMgM5qUBn8XsSEZQ== X-Google-Smtp-Source: AGHT+IEO1Addst46ofGtxfDAcyJAfRa7cWyZNqzRhdZXtyiIrODFKfx6qBjS5jqvhrfaOM+pKspNkg== X-Received: by 2002:a17:902:e802:b0:223:26da:4b6f with SMTP id d9443c01a7336-22428895abfmr268969215ad.14.1741673992501; Mon, 10 Mar 2025 23:19:52 -0700 (PDT) Received: from [157.82.205.237] ([157.82.205.237]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22410a7f5dasm89029115ad.137.2025.03.10.23.19.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Mar 2025 23:19:52 -0700 (PDT) Message-ID: <217fb3ef-336d-4141-b47e-3236f2c22ec3@daynix.com> Date: Tue, 11 Mar 2025 15:19:47 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v9 5/6] selftest: tun: Add tests for virtio-net hashing To: Jason Wang Cc: Jonathan Corbet , Willem de Bruijn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Xuan Zhuo , Shuah Khan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kselftest@vger.kernel.org, Yuri Benditovich , Andrew Melnychenko , Stephen Hemminger , gur.stavi@huawei.com, Lei Yang , Simon Horman References: <20250307-rss-v9-0-df76624025eb@daynix.com> <20250307-rss-v9-5-df76624025eb@daynix.com> Content-Language: en-US From: Akihiko Odaki In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2025/03/10 13:03, Jason Wang wrote: > On Fri, Mar 7, 2025 at 7:02 PM Akihiko Odaki wrote: >> >> The added tests confirm tun can perform RSS and hash reporting, and >> reject invalid configurations for them. > > Let's be more verbose here. E.g what's the network topology used here. The network topology doesn't matter because this only tests the rx of one device. I can still add more details; it tests all supported hash types, and tests both the queue selection and reported hash values. And this message is wrong in terms that it does not test validation of configuration so it also needs correction. > >> >> Signed-off-by: Akihiko Odaki >> Tested-by: Lei Yang >> --- >> tools/testing/selftests/net/Makefile | 2 +- >> tools/testing/selftests/net/tun.c | 584 ++++++++++++++++++++++++++++++++++- >> 2 files changed, 576 insertions(+), 10 deletions(-) >> >> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile >> index 73ee88d6b043004be23b444de667a1d99a6045de..9772f691a9a011d99212df32463cdb930cf0a1a0 100644 >> --- a/tools/testing/selftests/net/Makefile >> +++ b/tools/testing/selftests/net/Makefile >> @@ -123,6 +123,6 @@ $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma >> $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto >> $(OUTPUT)/tcp_inq: LDLIBS += -lpthread >> $(OUTPUT)/bind_bhash: LDLIBS += -lpthread >> -$(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/ >> +$(OUTPUT)/io_uring_zerocopy_tx $(OUTPUT)/tun: CFLAGS += -I../../../include/ >> >> include bpf.mk >> diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/net/tun.c >> index 463dd98f2b80b1bdcb398cee43c834e7dc5cf784..acadeea7194eaea9416a605b47f99f7a5f1f80cd 100644 >> --- a/tools/testing/selftests/net/tun.c >> +++ b/tools/testing/selftests/net/tun.c >> @@ -2,21 +2,38 @@ >> >> #define _GNU_SOURCE >> >> +#include >> #include >> #include >> +#include > > Is this needed? Yes, it is for unshare(). > >> +#include >> #include >> #include >> #include >> #include >> -#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> #include >> +#include >> #include >> #include >> -#include >> -#include >> +#include >> +#include >> +#include >> +#include >> >> #include "../kselftest_harness.h" >> >> +#define TUN_HWADDR_SOURCE { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } >> +#define TUN_HWADDR_DEST { 0x02, 0x00, 0x00, 0x00, 0x00, 0x01 } >> +#define TUN_IPADDR_SOURCE htonl((172 << 24) | (17 << 16) | 0) >> +#define TUN_IPADDR_DEST htonl((172 << 24) | (17 << 16) | 1) >> + >> static int tun_attach(int fd, char *dev) >> { >> struct ifreq ifr; >> @@ -39,7 +56,7 @@ static int tun_detach(int fd, char *dev) >> return ioctl(fd, TUNSETQUEUE, (void *) &ifr); >> } >> >> -static int tun_alloc(char *dev) >> +static int tun_alloc(char *dev, short flags) >> { >> struct ifreq ifr; >> int fd, err; >> @@ -52,7 +69,8 @@ static int tun_alloc(char *dev) >> >> memset(&ifr, 0, sizeof(ifr)); >> strcpy(ifr.ifr_name, dev); >> - ifr.ifr_flags = IFF_TAP | IFF_NAPI | IFF_MULTI_QUEUE; >> + ifr.ifr_flags = flags | IFF_TAP | IFF_NAPI | IFF_NO_PI | >> + IFF_MULTI_QUEUE; >> >> err = ioctl(fd, TUNSETIFF, (void *) &ifr); >> if (err < 0) { >> @@ -64,6 +82,40 @@ static int tun_alloc(char *dev) >> return fd; >> } >> >> +static bool tun_add_to_bridge(int local_fd, const char *name) >> +{ > > I wonder if a packet socket is more convenient here. I'll try it. Thanks for suggestion. Regards, Akihiko Odaki > > Thanks >