Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp162200pxb; Wed, 24 Feb 2021 22:06:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfLbDzFPRCDunC1FDGunzA+0Zf4vQkI7ssCeg5Y/GG7s4hQ8VZTUVoVz9krooAxBhv2k9p X-Received: by 2002:a17:906:f19a:: with SMTP id gs26mr1089638ejb.545.1614233192315; Wed, 24 Feb 2021 22:06:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614233192; cv=none; d=google.com; s=arc-20160816; b=iTmEtdnDxIA29TyxkLXqf2C4Iu3lTQI6tazXibJkmk+0SoQgWCza0VGVB0/pWoPkuN VLQsffWMJc9PYHdFa56l8RiPm9hKXTVmQUagi2a3filNCgYYLrDziODKmqbYTQo9dV/c zgbVsGve7wvjXRGzTXoaSr8t/1SNSkeAjg7/zsajvMJBpoEHBWxDAnZRSf2yJ0TKtRrL +H0T8Sd/IjUxf3rsyK4QPJL1v1QFJM9TPtuaZTENRIG0oN61mg33PDXCIHJqoauiIe/1 fxK+xS8BYGq9YhHa/1hYVDaqzkD75d0hyGTTAEjIC1l2eHn78Fx2kVrkWzSDi/T6dbtY LBZw== 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 :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=af5FXujGEIkpTuySXzoGyvvNnwH+HliU+Tx4J8/BjsM=; b=d8PbpmGyfvGGL8ZD21lep4WycxCSen17AOK6j7Q6T2ReWOkGdIJETEf/l8jH/P7ZF/ AVIslgR1B4lhMIEpPWpE08mo3vOpV5GaZ5kY/tz2h/aJftOIBrSTPLLs5CTs6p2i3Tnz DIbswhG8jV6PipkdByfzq2acZn7jjyKCyZHeyjt2kJ+9v25OugsHjw0EOGug9zhyAOHV S/bDKXpoDDeM2BKfrlz6vDOlJHZqqNE2ZRZwZyUP8CaMP//wVugkpAIQY2tKAL63whVO f1+Li2nEciFcLIZ1F4B/gJ2gcxCBJNUMo2nkjTj5oOPJ4YLjzkNtYbaLBmol+263yiic Qb1w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt14si2897699ejb.466.2021.02.24.22.06.09; Wed, 24 Feb 2021 22:06:32 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234339AbhBYCoM (ORCPT + 99 others); Wed, 24 Feb 2021 21:44:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:42012 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbhBYCoJ (ORCPT ); Wed, 24 Feb 2021 21:44:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B1F41AE71; Thu, 25 Feb 2021 02:43:27 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Thu, 25 Feb 2021 13:42:47 +1100 Subject: [PATCH 4/5] mountd: add --cache-use-ipaddr option to force use_ipaddr Cc: Linux NFS Mailing list Message-ID: <161422096789.28256.15609412723964905025.stgit@noble> In-Reply-To: <161422077024.28256.15543036625096419495.stgit@noble> References: <161422077024.28256.15543036625096419495.stgit@noble> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: NeilBrown When logging authentication requests, it can be easier to read the logs if clients are always identified by IP address, not intermediate names like netgroups or subnets. To allow this, add --cache-use-ipaddr or -i which tell mountd to always enable use_ipaddr. Signed-off-by: NeilBrown --- support/export/auth.c | 4 ++++ utils/mountd/mountd.c | 8 +++++++- utils/mountd/mountd.man | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/support/export/auth.c b/support/export/auth.c index 0bfa77d18469..cea376300d01 100644 --- a/support/export/auth.c +++ b/support/export/auth.c @@ -66,6 +66,10 @@ check_useipaddr(void) int old_use_ipaddr = use_ipaddr; unsigned int len = 0; + if (use_ipaddr > 1) + /* fixed - don't check */ + return; + /* add length of m_hostname + 1 for the comma */ for (clp = clientlist[MCL_NETGROUP]; clp; clp = clp->m_next) len += (strlen(clp->m_hostname) + 1); diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 59eddf79fd2e..dafcc35ca9c2 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -75,9 +75,10 @@ static struct option longopts[] = { "manage-gids", 0, 0, 'g' }, { "no-udp", 0, 0, 'u' }, { "log-auth", 0, 0, 'l'}, + { "cache-use-ipaddr", 0, 0, 'i'}, { NULL, 0, 0, 0 } }; -static char shortopts[] = "o:nFd:p:P:hH:N:V:vurs:t:gl"; +static char shortopts[] = "o:nFd:p:P:hH:N:V:vurs:t:gli"; #define NFSVERSBIT(vers) (0x1 << (vers - 1)) #define NFSVERSBIT_ALL (NFSVERSBIT(2) | NFSVERSBIT(3) | NFSVERSBIT(4)) @@ -681,6 +682,8 @@ read_mountd_conf(char **argv) num_threads = conf_get_num("mountd", "threads", num_threads); reverse_resolve = conf_get_bool("mountd", "reverse-lookup", reverse_resolve); ha_callout_prog = conf_get_str("mountd", "ha-callout"); + if (conf_get_bool("mountd", "cache-use-ipaddr", 0)) + use_ipaddr = 2; s = conf_get_str("mountd", "state-directory-path"); if (s && !state_setup_basedir(argv[0], s)) @@ -803,6 +806,9 @@ main(int argc, char **argv) case 'l': xlog_sconfig("auth", 1); break; + case 'i': + use_ipaddr = 2; + break; case 0: break; case '?': diff --git a/utils/mountd/mountd.man b/utils/mountd/mountd.man index df4e5356cb05..44d237e56110 100644 --- a/utils/mountd/mountd.man +++ b/utils/mountd/mountd.man @@ -118,6 +118,23 @@ section. will always log authentication responses to MOUNT requests when NFSv3 is used, but to get similar logs for NFSv4, this option is required. .TP +.BR \-i " or " \-\-cache\-use\-ipaddr +Normally each client IP address is matched against each host identifier +(name, wildcard, netgroup etc) found in +.B /etc/exports +and a combined identity is formed from all matching identifiers. +Often many clients will map to the same combined identity so performing +this mapping reduces the number of distinct access details that the +kernel needs to store. +Specifying the +.B \-i +option suppresses this mapping so that access to each filesystem is +requested and cached separately for each client IP address. Doing this +can increase the burden of updating the cache slightly, but can make the +log messages produced by the +.B -l +option easier to read. +.TP .B \-F " or " \-\-foreground Run in foreground (do not daemonize) .TP @@ -248,6 +265,7 @@ Values recognized in the .B [mountd] section include .BR manage-gids , +.BR cache\-use\-ipaddr , .BR descriptors , .BR port , .BR threads ,