Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2147844iob; Fri, 20 May 2022 03:11:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIegtS+W+0pe/mLiaUFbb/V+Tb3ex5Non/K+GUvF+2HRfDZ0XrUnJALXYlsMMD9lS9DmQr X-Received: by 2002:aa7:cad4:0:b0:428:715f:5ce4 with SMTP id l20-20020aa7cad4000000b00428715f5ce4mr10366804edt.124.1653041482209; Fri, 20 May 2022 03:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653041482; cv=none; d=google.com; s=arc-20160816; b=B7Ecx88CSrMFDrXWzIQTPjelwZnfssnRkLdnQT+zIfkyaBYEUPbEiZMxsr1f2liGWn f4g3vaWirWsOuZ4jj1BTvI36n1G6u/qKWqP87Mgml2m/qY7N40h1HAs7LnesA+CF+jvj PgarizgJnhB7t5QHQob4sDcMGe/vnSnfUYRiAfnTYEm7ZGxBRS4ZXnrLoFgCeeoPv9FO kgakjnYeBFT5pGwf9gY/W4ob0DpsSqaWb+WA66Gn0Imf5RvP6SvDWUYYHsu0Zg62ZhN2 /Y9dj8SjfeKZYYunrONjzkEZNyE2X3Wv83bN63xQwIXzIiZGYsp/Cpa3PHCfJZJ0Fwi7 PjAQ== 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=Oe5v/GGq49RZ4BGPJk/kMuOiOMHju3sdiVKJFl4uGmQ=; b=QlkxsA04CbpTUL2fHEsw1TXs43eAgNnUY0yH5or8orAWB5PluKyezg1f0qM2OXDT/m gKftGh6Ha3cvpFvnr5uudBqWEqaJqwUCJpSZUgCdPbKTAtKbVJ47I5INHzdoSTBRQVbq MFtftbul8eBeQv1GMkijs5PHv3rYxM8w7gLRPOJmyLQJJ91CUOxv4R2ZAAccfUWZ0KV6 Qn8thMKGsQERANOlZOmzS0VaudPntsvBVIBKGmzn+BP77XnG8AUA+O7ILi4OqTwP34uL utC1GO77Y1SwQOpYHiWtiU7JiFBxx6Db7lJ/ngxlKO/m6S4JPtMnAeq8b2nuTYKHvu6l PkRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s+587dhU; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji9-20020a170907980900b006e892eb5798si8410798ejc.808.2022.05.20.03.10.28; Fri, 20 May 2022 03:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s+587dhU; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233195AbiESPux (ORCPT + 99 others); Thu, 19 May 2022 11:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241731AbiESPt1 (ORCPT ); Thu, 19 May 2022 11:49:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6BF7CB28 for ; Thu, 19 May 2022 08:47:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 85A26B825F6 for ; Thu, 19 May 2022 15:47:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5474C34113; Thu, 19 May 2022 15:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652975249; bh=KA1DpMTgU5IhJ9T8CU20S/Ui/1sVmA4bIeBdoK+Xdj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+587dhUThgJJ4D1dqxYo6oljF093GRZskeDVShJJ48jS8VinwhiXS+KwPq8v8dVP 5c/lPZZ7QL1p87QdC86oo0p0hNKgdXDWhvYTfotIE1bAT4Dkg7X6L+HzvZjY2+EhW6 awYJ1lBkdom1S+3euMVgwspzR4mHuvfJCVtJc0npHjfdZcwNuvPj1phWMD/jhhtHlW 14GztBrjlVVtcfPHEigA2w01Rly/FMUqfOqsV7vHcCT7EmJ0t9GT6gYT3Fw+52zeWt qBP9c2DZsAIbIH1+xatj64YnKl0SfVw7N3yJm+zAH44WCzNgH4FXKsrgy3cnk0FAp9 NCXicgzplSaWA== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt Date: Thu, 19 May 2022 11:47:27 -0400 Message-Id: <20220519154727.3577715-2-anna@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220519154727.3577715-1-anna@kernel.org> References: <20220519154727.3577715-1-anna@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Anna Schumaker 'main' xprts cannot be set offline or removed, so print a helpful error message in this case instead of a cryptic 'invalid argument' message. Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 2a69eacd3103..d2110ad6de93 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -90,10 +90,18 @@ class Xprt: self.dstaddr = write_addr_file(self.path / "dstaddr", newaddr) def set_state(self, state): + if self.info.get("main_xprt"): + raise Exception(f"Main xprts cannot be set {state}") with open(self.path / "xprt_state", 'w') as f: f.write(state) self.read_state() + def remove(self): + if self.info.get("main_xprt"): + raise Exception("Main xprts cannot be removed") + self.set_state("offline") + self.set_state("remove") + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.set_defaults(func=Xprt.show, xprt=None) @@ -139,8 +147,7 @@ class Xprt: if args.property == "dstaddr": xprt.set_dstaddr(socket.gethostbyname(args.newaddr[0])) elif args.property == "remove": - xprt.set_state("offline") - xprt.set_state("remove") + xprt.remove() else: xprt.set_state(args.property) print(xprt) -- 2.36.1