Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp178316pxf; Wed, 31 Mar 2021 20:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyof6Bk8uYLnFFbX7QVTt1Rkq+wg/ciqYO2ndXbS/h+U4jEP7cqaR45uZ8eRJe2twfIFo+s X-Received: by 2002:a17:906:73cd:: with SMTP id n13mr6843546ejl.535.1617249314180; Wed, 31 Mar 2021 20:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617249314; cv=none; d=google.com; s=arc-20160816; b=Ad6iFLYo78h4Pug3Xre0rkapmxAl681e3CNefyknRHAgsnfoDOsNbIkJT7m4KZALbA RueeDHNRBCG4bBM9tjNTee3zvv+rBaWXeWGpkJZSvPTOwSpP+hLA/hOTiLcACzMOaGA2 KTOv1rOEcbAGMv047gUqygZaDpJKFdum0f4mwauxykOq4Bk4lZRzpbNSNyJTDehpAL4v muxSr9v9WQzKb4GtLv76Bq1uc7094Y35nTUlORtHxat0P5IGWz87iitHpIXt0D9/Hovj wySz2OZnLCOaSHUCI0GVmsX2bLo0PWMS4CqFEORdsYXTNYrX4cVRciUmaM2V7bbcIeGk xb2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zvMQ+DKleHJx90mAG9sNLyUQqL6auJ6HQgtidzz+V+A=; b=p2KQmwzGsPfvjr+rRDwE0WekF1+WUF7pzV4Oke3u8bxKtZTMKEKZ/wdNUTFdmp7g+K jzpN1SCF9kHvVrHTwtNW6tKnxG7LEvSBCshS2JO0GtkRUsMhaYN8fkKQdI28zeNIddEq jHMdyNJ3P5eH2bVGq9XEyaHmbThvIkm4q2BiOeNJ5eyqUzs5IGZpx7Qo19NNXjjw79Oe 1pZYOO6/bXg+0lT3uowyHXX0owgqQGjpMWCLliPNOITD8j1gfHAB3/8dfkR+DWYcpnaF l4IraqEv3RqaFdBZPKSI49NPYOCkLOQe5MYvo15m2L1NuDCC8sqxMZmUQ97zZQIheihB bULg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si3183452ejx.725.2021.03.31.20.54.51; Wed, 31 Mar 2021 20:55:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232491AbhDADx7 (ORCPT + 99 others); Wed, 31 Mar 2021 23:53:59 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:5084 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbhDADxl (ORCPT ); Wed, 31 Mar 2021 23:53:41 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=eguan@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0UU1.4-E_1617249209; Received: from localhost(mailfrom:eguan@linux.alibaba.com fp:SMTPD_---0UU1.4-E_1617249209) by smtp.aliyun-inc.com(127.0.0.1); Thu, 01 Apr 2021 11:53:29 +0800 Date: Thu, 1 Apr 2021 11:53:29 +0800 From: Eryu Guan To: trondmy@kernel.org Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia Subject: Re: [PATCH] NFS: Fix up the support for CONFIG_NFS_DISABLE_UDP_SUPPORT Message-ID: <20210401035329.GR95214@e18g06458.et15sqa> References: <20210330134010.61313-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210330134010.61313-1-trondmy@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Mar 30, 2021 at 09:40:10AM -0400, trondmy@kernel.org wrote: > From: Trond Myklebust > > Rather than removing the support in nfs_init_timeout_values(), we should > just fix up the validation checks in the mount option parsers. > > Signed-off-by: Trond Myklebust Add a 'Fixes' tag? i.e. Fixes: b24ee6c64ca7 ("NFS: allow deprecation of NFS UDP protocol") Thanks, Eryu > --- > fs/nfs/client.c | 2 -- > fs/nfs/fs_context.c | 54 +++++++++++++++++++++++++++++---------------- > 2 files changed, 35 insertions(+), 21 deletions(-) > > diff --git a/fs/nfs/client.c b/fs/nfs/client.c > index 94d47be1d1f6..2aeb4e52a4f1 100644 > --- a/fs/nfs/client.c > +++ b/fs/nfs/client.c > @@ -476,7 +476,6 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, > to->to_maxval = to->to_initval; > to->to_exponential = 0; > break; > -#ifndef CONFIG_NFS_DISABLE_UDP_SUPPORT > case XPRT_TRANSPORT_UDP: > if (retrans == NFS_UNSPEC_RETRANS) > to->to_retries = NFS_DEF_UDP_RETRANS; > @@ -487,7 +486,6 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, > to->to_maxval = NFS_MAX_UDP_TIMEOUT; > to->to_exponential = 1; > break; > -#endif > default: > BUG(); > } > diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c > index 902db1262d2b..cdf32b9a6c35 100644 > --- a/fs/nfs/fs_context.c > +++ b/fs/nfs/fs_context.c > @@ -283,20 +283,40 @@ static int nfs_verify_server_address(struct sockaddr *addr) > return 0; > } > > +#ifdef CONFIG_NFS_DISABLE_UDP_SUPPORT > +static bool nfs_server_transport_udp_invalid(const struct nfs_fs_context *ctx) > +{ > + return true; > +} > +#else > +static bool nfs_server_transport_udp_invalid(const struct nfs_fs_context *ctx) > +{ > + if (ctx->version == 4) > + return true; > + return false; > +} > +#endif > + > /* > * Sanity check the NFS transport protocol. > - * > */ > -static void nfs_validate_transport_protocol(struct nfs_fs_context *ctx) > +static int nfs_validate_transport_protocol(struct fs_context *fc, > + struct nfs_fs_context *ctx) > { > switch (ctx->nfs_server.protocol) { > case XPRT_TRANSPORT_UDP: > + if (nfs_server_transport_udp_invalid(ctx)) > + goto out_invalid_transport_udp; > + break; > case XPRT_TRANSPORT_TCP: > case XPRT_TRANSPORT_RDMA: > break; > default: > ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP; > } > + return 0; > +out_invalid_transport_udp: > + return nfs_invalf(fc, "NFS: Unsupported transport protocol udp"); > } > > /* > @@ -305,8 +325,6 @@ static void nfs_validate_transport_protocol(struct nfs_fs_context *ctx) > */ > static void nfs_set_mount_transport_protocol(struct nfs_fs_context *ctx) > { > - nfs_validate_transport_protocol(ctx); > - > if (ctx->mount_server.protocol == XPRT_TRANSPORT_UDP || > ctx->mount_server.protocol == XPRT_TRANSPORT_TCP) > return; > @@ -929,6 +947,7 @@ static int nfs23_parse_monolithic(struct fs_context *fc, > struct nfs_fh *mntfh = ctx->mntfh; > struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; > int extra_flags = NFS_MOUNT_LEGACY_INTERFACE; > + int ret; > > if (data == NULL) > goto out_no_data; > @@ -1054,6 +1073,10 @@ static int nfs23_parse_monolithic(struct fs_context *fc, > goto generic; > } > > + ret = nfs_validate_transport_protocol(fc, ctx); > + if (ret) > + return ret; > + > ctx->skip_reconfig_option_check = true; > return 0; > > @@ -1155,6 +1178,7 @@ static int nfs4_parse_monolithic(struct fs_context *fc, > { > struct nfs_fs_context *ctx = nfs_fc2context(fc); > struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; > + int ret; > char *c; > > if (!data) { > @@ -1227,9 +1251,9 @@ static int nfs4_parse_monolithic(struct fs_context *fc, > ctx->acdirmin = data->acdirmin; > ctx->acdirmax = data->acdirmax; > ctx->nfs_server.protocol = data->proto; > - nfs_validate_transport_protocol(ctx); > - if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) > - goto out_invalid_transport_udp; > + ret = nfs_validate_transport_protocol(fc, ctx); > + if (ret) > + return ret; > done: > ctx->skip_reconfig_option_check = true; > return 0; > @@ -1240,9 +1264,6 @@ static int nfs4_parse_monolithic(struct fs_context *fc, > > out_no_address: > return nfs_invalf(fc, "NFS4: mount program didn't pass remote address"); > - > -out_invalid_transport_udp: > - return nfs_invalf(fc, "NFS: Unsupported transport protocol udp"); > } > #endif > > @@ -1307,6 +1328,10 @@ static int nfs_fs_context_validate(struct fs_context *fc) > if (!nfs_verify_server_address(sap)) > goto out_no_address; > > + ret = nfs_validate_transport_protocol(fc, ctx); > + if (ret) > + return ret; > + > if (ctx->version == 4) { > if (IS_ENABLED(CONFIG_NFS_V4)) { > if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA) > @@ -1315,9 +1340,6 @@ static int nfs_fs_context_validate(struct fs_context *fc) > port = NFS_PORT; > max_namelen = NFS4_MAXNAMLEN; > max_pathlen = NFS4_MAXPATHLEN; > - nfs_validate_transport_protocol(ctx); > - if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) > - goto out_invalid_transport_udp; > ctx->flags &= ~(NFS_MOUNT_NONLM | NFS_MOUNT_NOACL | > NFS_MOUNT_VER3 | NFS_MOUNT_LOCAL_FLOCK | > NFS_MOUNT_LOCAL_FCNTL); > @@ -1326,10 +1348,6 @@ static int nfs_fs_context_validate(struct fs_context *fc) > } > } else { > nfs_set_mount_transport_protocol(ctx); > -#ifdef CONFIG_NFS_DISABLE_UDP_SUPPORT > - if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) > - goto out_invalid_transport_udp; > -#endif > if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA) > port = NFS_RDMA_PORT; > } > @@ -1363,8 +1381,6 @@ static int nfs_fs_context_validate(struct fs_context *fc) > out_v4_not_compiled: > nfs_errorf(fc, "NFS: NFSv4 is not compiled into kernel"); > return -EPROTONOSUPPORT; > -out_invalid_transport_udp: > - return nfs_invalf(fc, "NFS: Unsupported transport protocol udp"); > out_no_address: > return nfs_invalf(fc, "NFS: mount program didn't pass remote address"); > out_mountproto_mismatch: > -- > 2.30.2