From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 8CF0747DD67 for ; Tue, 14 Jul 2026 14:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784039379; cv=none; b=Ahi8Q63/1D5YD2xRO7OXCxhy40GzDGOnrIIvc4Sld4i4kucJiHamplRr/hJ5LpCj7kB1nb36R1OnIFL48LzIu75TbUDa9w2wyk4vS0N6vlZ1yMkYtcZxnbH/hMsciCX0IrIemADxN2beY5PiJO8kxi5vF1D4Gs5jMFKAP+IFuOM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784039379; c=relaxed/simple; bh=fj0Q6ihUmYqKUkY8KaHXFWF5Aioa8BtTYy9MtuieBMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qci1+vKSox3x9d+TTHMZqWyC+d1XIffv8+sgKQn7DvpgPe83QRMPuTisHOAgnVd8pE1Pq9K+vjPuW0RjfldqJ47p2FLWmd+iGUeiiUDgYK8cvbqTG+wfuIIc/tM2L53XO8Q8u2bbjY2/Tf46RO10V62MbKYmbZoyT9FkwvZJ6o0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20251104.gappssmtp.com header.i=@resnulli-us.20251104.gappssmtp.com header.b=Rw5eW6pp; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20251104.gappssmtp.com header.i=@resnulli-us.20251104.gappssmtp.com header.b="Rw5eW6pp" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-4720f3bf164so529076f8f.1 for ; Tue, 14 Jul 2026 07:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20251104.gappssmtp.com; s=20251104; t=1784039375; x=1784644175; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=q+RolV7SjzshTN5zqSzxTVIaSTGOodHrW0P7odUB/p4=; b=Rw5eW6ppmDIrndA6q1mBhiSrnWhnU2hXHfxl2KFtVK1zkFOxQ43DK6GNmKOJP0oX5q r3vwazSVBJXfppL7Hoi94Ew9DpoaJut7vGKVwOYJ8an9S2GM0nQ7Oe3jGQcJVXuqWiua P9pqV36DnvKqa+LewDRIhJTP2Qfnov4Trpk3SgB/Znf3aIF8a7Jb+Fft3Etng1+OQBG8 nlajd3Mu024JqN050emv6K2zEa6bKNEL0URvLDxBJSz9kSUx1T2f51I0X3H0sB40oVht z7O38q89XSmUmFTTh3hg/YndietSfsrcqhAaQtd3sKVGd6Yzniz2akLTlCOK6RLGw8lW /4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784039375; x=1784644175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=q+RolV7SjzshTN5zqSzxTVIaSTGOodHrW0P7odUB/p4=; b=XLcE7Z+wgcEV+J3w++HkkoaIxLBthH2nCyUAGwtV9XXkpyp4GCNBt/XlK1KJ2BDbRN S973glMyuL80Uds+yK/whYWvNM5CLKHbJ6X6esrtL6NOSLsRalPN79UYExu0fKsMOx/1 mR2T4CaV6gR39ULbaja+s22OhFWGPeZBgN1ryQtgCWdW9wHz32GEh9DDzYNAXVmIxeUD B4cxG5K89Pvj9Hgg4NepLHPeJBPX9RRT3Cs8/gBm5FuFZFRA97qdg5lr2WGQk+lRlzhH jn3BAHamJ0Mteg7MnbgLel1kredbc9TFPrjXy5fuTN4rx6ZOiBgtufbFLfMeqWSwJqpj 9cLA== X-Forwarded-Encrypted: i=1; AHgh+RrAvk/XP2VUjuSg3RXGeYkjd5JDQIvf0Owhdh1AbfiH37xTggnHKKNGFslUXjXvZ4m8QJMcDTM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywd6xDF8hOggEttBBpmpQtPuZvWZQdhHZt14PSfhwbZbPBhGUnI YQOkGKShJSb8a5qsxD7g/iZVTKGEWJ0rhbU65Qy+JiLu/J8xodD1WaACEVC+b+4YS80= X-Gm-Gg: AfdE7cnwUeRj19SYCXA/QFWsl8lcnvUMxXLqpMM024MGVvDBHGbgX8edLLO2TfGagPZ qipTU3SMeiCPcabIr2btyFZWYmEtfaL65kp2RaKUJRSB+X7pAGt7vXHB/2AnF/7RriWLbqTzr1D Y9LMplFzUsVESRy8neqgHSfNPlhuS7FJe3Z82yWsMc6MU+b6FjYHL0k8BKDseG6vHg8N1PPmLUF H3htD5Fu+s7tCYnvdnkwv2Hqe//AhZTxeBmcsmsSkRY5lM6cMLGvmtgZbwSRkhMcJRLkP7YDG3v cvHwzFwbLp6I48YWoV77c7qAAKp6W+VpLJtv7OQj9eg6xq3U0hr02ot2M8fMZ2U7r0C/VhX+yo5 AOdpIlmXcCw238a7ia9PF+psYoE1gHfolgmy8KdU84yw+cWWhDha569UUrMzQj3ujVx9LW8Ygfe fw5o0nKGaW3UQrYf2sGIX97g== X-Received: by 2002:a05:6000:1866:b0:478:7019:e5ef with SMTP id ffacd0b85a97d-47ef6986d21mr22449614f8f.21.1784039374656; Tue, 14 Jul 2026 07:29:34 -0700 (PDT) Received: from localhost ([140.209.217.211]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f464c9cc3sm8626412f8f.35.2026.07.14.07.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 07:29:34 -0700 (PDT) From: Jiri Pirko To: linux-rdma@vger.kernel.org Cc: cgroups@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org, jgg@ziepe.ca, leon@kernel.org, parav@nvidia.com, mbloch@nvidia.com, cmeiohas@nvidia.com, roman.gushchin@linux.dev, bvanassche@acm.org, zyjzyj2000@gmail.com, shuah@kernel.org, tj@kernel.org, mkoutny@suse.com, hannes@cmpxchg.org, alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com, wenjia@linux.ibm.com, yanjun.zhu@linux.dev, cui.tao@linux.dev Subject: [PATCH rdma-next v2 01/14] RDMA/core: Pass the net namespace to the device name lookups Date: Tue, 14 Jul 2026 16:29:14 +0200 Message-ID: <20260714142927.1298897-2-jiri@resnulli.us> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260714142927.1298897-1-jiri@resnulli.us> References: <20260714142927.1298897-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jiri Pirko Prepare for per-netns RDMA device names by passing the target net namespace through the name lookup and allocation helpers. Keep current global uniqueness behaviour. Signed-off-by: Jiri Pirko --- drivers/infiniband/core/device.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index b8193e077a74..de610f52c9b2 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -351,7 +351,8 @@ void ib_device_put(struct ib_device *device) } EXPORT_SYMBOL(ib_device_put); -static struct ib_device *__ib_device_get_by_name(const char *name) +static struct ib_device *__ib_device_get_by_name(const char *name, + const struct net *net) { struct ib_device *device; unsigned long index; @@ -395,7 +396,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name) return 0; } - if (__ib_device_get_by_name(name)) { + if (__ib_device_get_by_name(name, rdma_dev_net(ibdev))) { up_write(&devices_rwsem); return -EEXIST; } @@ -435,7 +436,8 @@ int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim) return 0; } -static int alloc_name(struct ib_device *ibdev, const char *name) +/* Pick a free index for the '%d' style @name pattern. */ +static int alloc_name_id(struct net *net, const char *name) { struct ib_device *device; unsigned long index; @@ -462,15 +464,22 @@ static int alloc_name(struct ib_device *ibdev, const char *name) } rc = ida_alloc(&inuse, GFP_KERNEL); - if (rc < 0) - goto out; - - rc = dev_set_name(&ibdev->dev, name, rc); out: ida_destroy(&inuse); return rc; } +static int alloc_name(struct ib_device *ibdev, const char *name) +{ + int id; + + id = alloc_name_id(rdma_dev_net(ibdev), name); + if (id < 0) + return id; + + return dev_set_name(&ibdev->dev, name, id); +} + static void ib_device_release(struct device *device) { struct ib_device *dev = container_of(device, struct ib_device, dev); @@ -1223,7 +1232,8 @@ static int assign_name(struct ib_device *device, const char *name) if (ret) goto out; - if (__ib_device_get_by_name(dev_name(&device->dev))) { + if (__ib_device_get_by_name(dev_name(&device->dev), + rdma_dev_net(device))) { ret = -ENFILE; goto out; } -- 2.54.0