Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1576504pxb; Tue, 8 Feb 2022 22:52:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/EMB2WOa20oV2n+86/p8GMG1J9uMkilkrKwmGCI0VV+7nXYeMZo5vjaIcqt8V59OvNIsb X-Received: by 2002:a05:6a00:8c5:: with SMTP id s5mr849161pfu.18.1644389552106; Tue, 08 Feb 2022 22:52:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389552; cv=none; d=google.com; s=arc-20160816; b=bvaGf644uwSd41y55isZpujY+gdiMvcOAvR3ZZIuAPnkQY56ejfHZ1DwXyUygAjLey wzm4Lw10O+YbtMEXKdbZCq8BT13lHq1G3TbQ6sutPbpfOqSq4ndOeIxnFdzZSPZfadUv cmPYRb2h/pKljcJXvLfamLluJnqsjJoCJGHedj85yuJuoahqwbFcjKLxCBdAIb13TSvk edHhohxrTTy6Y0YIz/hK/9PhpBw7pFejAlsebmZvq+fVOjUXC5My3jrUtLU6IxSg9/tr L0LbgH9n7OMz3tIntVwVzMU5OtJ0Ht/GNLyBG1lW12JbfVfPIZvHor8ve3og+Tpv6WXi e+Qw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=0S269LCjxWcMpGdhNWI0ipeissCmHiVKApI+iSPJoa4=; b=TTJyMmFI058wY+ZvklfV35jsaOqSQEasgyigUUdnrCHmdL93/3dp54kaSTbezuL+2/ sHibRFM8Hg16Sw2qIckhQl7//utidlx6RkWHqh7QQ/fvn77HMosAirirQzqAflcoBz7Q oe8w4TFMdTV8K7V+p2DDcJneGpR8Hx4V46nRGCD4IEhZhb8g9pNIxjhcKWdmQAMVnHIq qZE0m0tCGt2R7nRTtjyhHrItK6zedm2nwiWbcW1X3g8rAbGGp9ktVIIobVoZqOaeROdX I8KJ8kLLpX/AcD4Ix4a1ADAsFhsR5fJJArn1jfkOQdlXoKxQD0+S23a68LVGanxuZIfC C96g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RNgPN17a; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h123si16038435pgc.414.2022.02.08.22.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:52:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RNgPN17a; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3AEE5E05B1E3; Tue, 8 Feb 2022 22:30:45 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236429AbiBHWWc (ORCPT + 99 others); Tue, 8 Feb 2022 17:22:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386300AbiBHUEB (ORCPT ); Tue, 8 Feb 2022 15:04:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 369ADC0613CB for ; Tue, 8 Feb 2022 12:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644350639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0S269LCjxWcMpGdhNWI0ipeissCmHiVKApI+iSPJoa4=; b=RNgPN17awCJiB3KP8IJqzD7qaPqvA87+1nU06Gbn3I2s1cgkYftnI15mKB6Xaw/ETf/2jX cjDWLzgnSRbGR9rWHV1MYasZxU2ZFxSg5A/mLq+TacWZ5yWSNBIoQ1kqeaR1vBDytNzGo5 Agu2MGXkBzt6VOSn8CMMw8LUbbWwK/o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-EsehiE6HMS2AB9vZjrxXDQ-1; Tue, 08 Feb 2022 15:03:56 -0500 X-MC-Unique: EsehiE6HMS2AB9vZjrxXDQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C93A2F44; Tue, 8 Feb 2022 20:03:55 +0000 (UTC) Received: from bcodding.csb (ovpn-64-2.rdu2.redhat.com [10.10.64.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1B0D6AB83; Tue, 8 Feb 2022 20:03:54 +0000 (UTC) Received: by bcodding.csb (Postfix, from userid 24008) id 4042410C30F0; Tue, 8 Feb 2022 15:03:54 -0500 (EST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFSv4: use unique client identifiers in network namespaces Date: Tue, 8 Feb 2022 15:03:54 -0500 Message-Id: <6e05bf321ff50785360e6c339d111db368e7dfda.1644349990.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In order to differentiate client state, assign a random uuid to the uniquifing portion of the client identifier when a network namespace is created. Containers may still override this value if they wish to maintain stable client identifiers by writing to /sys/fs/nfs/net/client/identifier, either by udev rules or other means. Signed-off-by: Benjamin Coddington --- fs/nfs/sysfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c index 8cb70755e3c9..9b811323fd7f 100644 --- a/fs/nfs/sysfs.c +++ b/fs/nfs/sysfs.c @@ -167,6 +167,18 @@ static struct nfs_netns_client *nfs_netns_client_alloc(struct kobject *parent, return NULL; } +static void assign_unique_clientid(struct nfs_netns_client *clp) +{ + unsigned char client_uuid[16]; + char *uuid_str = kmalloc(UUID_STRING_LEN + 1, GFP_KERNEL); + + if (uuid_str) { + generate_random_uuid(client_uuid); + sprintf(uuid_str, "%pU", client_uuid); + rcu_assign_pointer(clp->identifier, uuid_str); + } +} + void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net) { struct nfs_netns_client *clp; @@ -174,6 +186,8 @@ void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net) clp = nfs_netns_client_alloc(nfs_client_kobj, net); if (clp) { netns->nfs_client = clp; + if (net != &init_net) + assign_unique_clientid(clp); kobject_uevent(&clp->kobject, KOBJ_ADD); } } -- 2.31.1