Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp719797pxu; Wed, 7 Oct 2020 14:10:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeJgYL6S4GLPT1Q/Kizlh8LFNE4fW0trJnJlEp7O7eLmCpgfN0m9JpJ+4YvAK8cvjA0McA X-Received: by 2002:aa7:d782:: with SMTP id s2mr5564028edq.111.1602105021718; Wed, 07 Oct 2020 14:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602105021; cv=none; d=google.com; s=arc-20160816; b=Ckuq0uuBo2T48kJAHy6LZ9Bq+CFCXf9TgD8CtiH/V4mjAAW0itRtBilgVNTAmL5ysg Up3Nqky3J55hxK4OpPNoOGUdAYRTZGYmMDmseYobJdlUylcVYjkd+7ZthwJ0apPH01RB awNBkFFB0arECHn0lxkcRNh6QTuyH/zWZg1lTBWrdCQ31cKi+wedyrdlgLkmZvMzIht1 KMrqcqVMAANA+Cj7rGdWcr+1eenapZv3xjTlCugX3JJ+rqHvBOoteherHONMeUc3Vy2K gcnTBZPA0+10rVa4ROodGkQZZBEwzF7Smp5MLQTSco5hzVo2L2ZDDXHqdUqSciSOMgA3 q7Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D65Gds5rUftB4hNUgNny/LRLFBpSCB0xJELGOGGawgY=; b=AtB5IUzjKs4Iof+ofQAEkscYaLpMS/5WdoHloSytZI9Rs2Dt+UmuRvdOtxqeoMw2AS 4Ure0889PgTXecseJMcd3wF55BvR+mL8JmrHCDjOovmz9lB4WD1z4lo1Z3X8bS7RRUG2 5/WIyp2QQcnQ9MZIIvEyyFNp6HtUmGkcKC2SHcuoC0xDAJ1VCmfsl3m64Y79/6RoOI4A dRF9kBa1RWRq2BOmo+rPmkxVo4omwC8zxnQu9H8Zsx3P4bKL1qwgL2GUSWDGoQeCR0ic Nt48a7JA3LOXmPrzWXkpUsHHcr+PsnG/k6DobzvKGBpnL5zp6vKwGb5OsbjCTBvCbvPr jOHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ys5VVr8z; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si2142003ejb.417.2020.10.07.14.09.52; Wed, 07 Oct 2020 14:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ys5VVr8z; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728292AbgJGVJa (ORCPT + 99 others); Wed, 7 Oct 2020 17:09:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728428AbgJGVJa (ORCPT ); Wed, 7 Oct 2020 17:09:30 -0400 Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net [68.36.133.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E253E2087D; Wed, 7 Oct 2020 21:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602104970; bh=oKoHzfk4Pdw+BEotzgkjisWZt/IwoCU5xdDP7N1iyU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ys5VVr8zn9yp9WM3whPTC69udHoT3i5MnAyNmUWkLesbLFrVDHWI/UR3kzXg4WwmD EC+2/ggWFwLWM4aFSV71HGLkCy9Cft6losCKTzKe7SgqN3AdeaBiWiJC39QfLZMMce tq0QWKWMcT0vf35IC3YOZYkizLZcEl+FvebNXd1A= From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set Date: Wed, 7 Oct 2020 17:07:20 -0400 Message-Id: <20201007210720.537880-3-trondmy@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201007210720.537880-2-trondmy@kernel.org> References: <20201007210720.537880-1-trondmy@kernel.org> <20201007210720.537880-2-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If a container sets a net namespace specific uniquifier, then use that in the setclientid/exchangeid process. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3a39887e0e6e..a1dd46e7440b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -63,6 +63,7 @@ #include "callback.h" #include "pnfs.h" #include "netns.h" +#include "sysfs.h" #include "nfs4idmap.h" #include "nfs4session.h" #include "fscache.h" @@ -6007,9 +6008,25 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp, } static size_t -nfs4_get_uniquifier(char *buf, size_t buflen) +nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen) { + struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); + struct nfs_netns_client *nn_clp = nn->nfs_client; + const char *id; + size_t len; + buf[0] = '\0'; + + if (nn_clp) { + rcu_read_lock(); + id = rcu_dereference(nn_clp->identifier); + if (id && *id != '\0') + len = strlcpy(buf, id, buflen); + rcu_read_unlock(); + if (len) + return len; + } + if (nfs4_client_id_uniquifier[0] != '\0') return strlcpy(buf, nfs4_client_id_uniquifier, buflen); return 0; @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp) 1; rcu_read_unlock(); - buflen = nfs4_get_uniquifier(buf, sizeof(buf)); + buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf)); if (buflen) len += buflen + 1; @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp) len = 10 + 10 + 1 + 10 + 1 + strlen(clp->cl_rpcclient->cl_nodename) + 1; - buflen = nfs4_get_uniquifier(buf, sizeof(buf)); + buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf)); if (buflen) len += buflen + 1; -- 2.26.2