From nobody Sat Nov 23 21:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1728370364; cv=none; d=zohomail.com; s=zohoarc; b=KRhqA/qW7femjEHeI5bgecbMScwW/P2GNe0nABtMz16hlQjW2T9P+3sQUCW/tb9WaHipwYUrQHFN/OzyfAdNuREGKXkZUbyAdZVMa8ntT5myRhyIINH5wTvrHrh38QiCmYQvdCJz9Vff13OklHrYIxJ5zz48oCS3KeTVIzFaf34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728370364; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=R1d7TDzHibv/EJuj9skVG1YdSpRjycErvD1ixQRqV18=; b=CnRF2RD4IlBhQcCqyv1IUOWr2cRcTbLNq4X3IemEMVsibs6WkyWuDZrqxK6+hFlHWC5DLERfvl4MkcmpyEUc6cu6LBQIdSHmegKvDkRXCZL1ChgEHLwwlGj0B20MjHgHVxB8Y03yRwdoqmxQmqywHLBadJUVH1i5TSXEZBJtUNU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728370364627930.1317771134395; Mon, 7 Oct 2024 23:52:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sy453-0002Ny-CI; Tue, 08 Oct 2024 02:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sy44z-0002EM-Pf for qemu-devel@nongnu.org; Tue, 08 Oct 2024 02:52:21 -0400 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sy44y-0006Zy-Fn for qemu-devel@nongnu.org; Tue, 08 Oct 2024 02:52:21 -0400 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-e260b747fdcso4793807276.3 for ; Mon, 07 Oct 2024 23:52:19 -0700 (PDT) Received: from localhost ([157.82.207.107]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71df0d7cfa4sm5483182b3a.196.2024.10.07.23.52.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2024 23:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1728370338; x=1728975138; darn=nongnu.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=R1d7TDzHibv/EJuj9skVG1YdSpRjycErvD1ixQRqV18=; b=JsfdUDwcq8b3hLJxgZ3yqpwaPODxs+QKrDSQulc7X+mZ5sTp2wnYQuewFej5z4ucvx ENg28ezCNcSce5ZHmFNqw9QLTrqSvy4MD5k5pfRGO47K5/EKd7VEhJs7l9iNHG0nRavi 1E8i3jxj/v60iVhIA3SMCrV4sEkQ5WyKekXsktyAxc/uEG1b2Pj3q+MuQazuWCwYX2x9 7a/ly77hlew4+uG7RvtDmv2W9CuCsCVtrQZP6NVgpxSXIG6vIugpDKT+lGjDwV6JOupM TWnRs1Ek+0luGDbEK7SnwMwjJBNI/SmVGiFAl7e55KjZo/LbObhr5U3TYgeJ8UabUZ2n dZ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728370338; x=1728975138; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R1d7TDzHibv/EJuj9skVG1YdSpRjycErvD1ixQRqV18=; b=Q4O1GybhvTM5ZZXKD6Q1zKL1mD5hSbEc/sUMmqNgPEBvbMeCCYSi8UZyblyTBtJaaR R1ApFN9aDz2GB8f7im+W6VmhKOJWf2h6/Yf8JfZkZ0ojhO+Shv67t88nDsizTqDB67dI PX/QUVrINJeHIzIteafMAbkwihCh51h0owLJEWGfFOgmxHY1gS5VTTVaJPPFgvxL5qFh u7xtFJWtnVGMurKVK3TG9bC/8NzWJSybrIvZjdOMaLwa1HlnEj+s1XtfOs4lkpLx/0QF Viv/1yUSPb0gyByiDBbGR3RDMOGCjhpEkAhfE3SOW2/n7XUhzzPZR3y0QfSNWwue59Hd 9oEQ== X-Gm-Message-State: AOJu0YzQmxa+h1Td/AgSvmdlmVS9G3C85DftAWUawYLOm4U9BNX6lT+G LZ0Z3Mnp5qjUHDKmVkHVKhZwKK0HnxAMVD8rsAS0wFpK3KO/Sc9k1eu6ndJZgAXMGy13ZzgBm4z iT3g= X-Google-Smtp-Source: AGHT+IFyGdTwdB2dnbmjggR66QYYcYwSp+mRMj4MaBhJQmLJHND0RjHZxn8iEEbUmL6BhVnfsBuRbA== X-Received: by 2002:a05:6902:1b09:b0:e22:4f74:9590 with SMTP id 3f1490d57ef6-e289392b69fmr10035686276.27.1728370338132; Mon, 07 Oct 2024 23:52:18 -0700 (PDT) From: Akihiko Odaki Date: Tue, 08 Oct 2024 15:52:06 +0900 Subject: [PATCH] tap-linux: Open ipvtap and macvtap MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241008-macvtap-v1-1-2032caa25b6d@daynix.com> X-B4-Tracking: v=1; b=H4sIAJXWBGcC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxNDAwML3dzE5LKSxALdJENTo1TTxKQkE1NzJaDqgqLUtMwKsEnRsbW1ANN khjBZAAAA To: Jason Wang Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::b33; envelope-from=akihiko.odaki@daynix.com; helo=mail-yb1-xb33.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1728370366699116600 ipvtap and macvtap create a file for each interface unlike tuntap, which creates one file shared by all interfaces. Try to open a file dedicated to the interface first for ipvtap and macvtap. Signed-off-by: Akihiko Odaki --- net/tap-linux.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/net/tap-linux.c b/net/tap-linux.c index 1226d5fda2d9..22ec2f45d2b7 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -45,10 +45,21 @@ int tap_open(char *ifname, int ifname_size, int *vnet_h= dr, int len =3D sizeof(struct virtio_net_hdr); unsigned int features; =20 - fd =3D RETRY_ON_EINTR(open(PATH_NET_TUN, O_RDWR)); + + ret =3D if_nametoindex(ifname); + if (ret) { + g_autofree char *file =3D g_strdup_printf("/dev/tap%d", ret); + fd =3D open(file, O_RDWR); + } else { + fd =3D -1; + } + if (fd < 0) { - error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN); - return -1; + fd =3D RETRY_ON_EINTR(open(PATH_NET_TUN, O_RDWR)); + if (fd < 0) { + error_setg_errno(errp, errno, "could not open %s", PATH_NET_TU= N); + return -1; + } } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags =3D IFF_TAP | IFF_NO_PI; --- base-commit: 31669121a01a14732f57c49400bc239cf9fd505f change-id: 20241008-macvtap-b152e5abb457 Best regards, --=20 Akihiko Odaki