From patchwork Tue Jun 2 07:38:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarosh Arif X-Patchwork-Id: 70729 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C11FDA04EF; Tue, 2 Jun 2020 09:39:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BAA961BFB4; Tue, 2 Jun 2020 09:39:24 +0200 (CEST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by dpdk.org (Postfix) with ESMTP id A45E51BFAA for ; Tue, 2 Jun 2020 09:39:23 +0200 (CEST) Received: by mail-wr1-f52.google.com with SMTP id y17so2245846wrn.11 for ; Tue, 02 Jun 2020 00:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CEa159QDcQpHr5+EfhRTUtlrtjzmJHiz843tf6GUGl8=; b=eHCnMF03xzDYOvSKbo8m3vtqN37l3a5tpFOe5/CIMn7uwL8SieN+7vQO2N28Wxg8fj cDnuuasEM0uLFgvOPXCrhjhxgj2JcI+5e5kpuUf/Jh7dKs8znSy9IJEflwaI05zjeJtr K91ufsHEVVxjTlX16gX74vXxfxtQnoNMnj1D0StORCqtvMoVQg6MEGtx+7ffxcxvDVXP ltdoD2XJn2yW2VCaYg2FDX7dSfpFW+qWNgIVkTQGcEM8pgROAisQM0MElcxGdXPwfAIW yf1/y1mnO8QR9rJAVDI/JDUU2Zvz3Y+CRTzApP6ig9ZPAezEnFLWYf4+j5Qu+MfNq9MQ T7Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CEa159QDcQpHr5+EfhRTUtlrtjzmJHiz843tf6GUGl8=; b=IxbnrzLEplkKxeKBnsBcrNM7E5thKGB55G4Nj8jrpJTVbLCEqf1bqaSXGQmxCOgqsA AmXpXZoGtDCuMZhrzk/aiOseAtGbeIQ8GOg/tJFqRan5d0z6gBAGAh4rvRxfFY+JAszw i5Q2Pxr8ZorbrReN2c0Atsy7mUwBG2N/BP3GZnjFt+ExwKM/DgE+f/DK63PlI1NNN9n2 XjgiNzeKI+aYjJoTGiwjX6yGjn5T2R70eUdaapvX0lJSnXakjnP/BybN/CIv6bZITDYF 6JnEs98mnoehKhKnbQjK8PG6rOVbdAAW+BhyDkH18q9gvQSKKgy32KC7vbkjeQVXc2xy Mw5g== X-Gm-Message-State: AOAM530UncU4cZpDZnyg07J5/QvU0ZdjqQGk3UJ0CIA69N1erDQL9ddQ x+k+D9/MGhPZS1ne8SthQ4t9DDiJs5DEzTDE X-Google-Smtp-Source: ABdhPJwT6Evgw4j1EErEItz1XuAuS3W7i4Qb88GXqBfxXqei0jUdaKAlo/9elmSB11pcarU3JgpHIg== X-Received: by 2002:adf:df91:: with SMTP id z17mr24668656wrl.273.1591083562553; Tue, 02 Jun 2020 00:39:22 -0700 (PDT) Received: from localhost.localdomain ([39.40.11.211]) by smtp.gmail.com with ESMTPSA id f9sm2394397wre.65.2020.06.02.00.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 00:39:22 -0700 (PDT) From: Sarosh Arif To: dev@dpdk.org, thomas@monjalon.net Cc: m.bilal@emumba.com, stable@dpdk.org, john.mcnamara@intel.com, Sarosh Arif Date: Tue, 2 Jun 2020 12:38:13 +0500 Message-Id: <20200602073813.1484-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200601084028.20872-1-sarosh.arif@emumba.com> References: <20200601084028.20872-1-sarosh.arif@emumba.com> Subject: [dpdk-dev] [PATCH v4] usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Combine https://patches.dpdk.org/patch/67855/ with v2 of this patch to fix the overall behaviour of dpdk-setup.sh on non-alphanumeric inputs. Instead of crashing the script will prompt the user to re-enter the input in case of non-alphanumeric input. Bugzilla ID: 419 Signed-off-by: Sarosh Arif Signed-off-by: Muhammad Bilal --- v4: fix signoff --- usertools/dpdk-setup.sh | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/usertools/dpdk-setup.sh b/usertools/dpdk-setup.sh index e5bbe9fee..69cd1d2bd 100755 --- a/usertools/dpdk-setup.sh +++ b/usertools/dpdk-setup.sh @@ -320,14 +320,18 @@ set_non_numa_pages() echo " enter '64' to reserve 64 * 2MB pages" echo -n "Number of pages: " read Pages + numeric="^[[:digit:]]+$" + PG_PATH="/sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}" + if [[ $Pages =~ $numeric ]]; then + echo "echo $Pages > $PG_PATH/nr_hugepages" > .echo_tmp + echo "Reserving hugepages" + sudo sh .echo_tmp + rm -f .echo_tmp + create_mnt_huge + else + echo "Please enter a numeric value" + fi - echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" > .echo_tmp - - echo "Reserving hugepages" - sudo sh .echo_tmp - rm -f .echo_tmp - - create_mnt_huge } # @@ -343,10 +347,16 @@ set_numa_pages() echo " enter '64' to reserve 64 * 2MB pages on each node" echo > .echo_tmp + numeric="^[[:digit:]]+$" for d in /sys/devices/system/node/node? ; do node=$(basename $d) echo -n "Number of pages for $node: " read Pages + while [[ ! "$Pages" =~ $numeric ]]; do + echo "Please enter a numeric value" + echo -n "Number of pages for $node: " + read Pages + done echo "echo $Pages > $d/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" >> .echo_tmp done echo "Reserving hugepages" @@ -592,10 +602,15 @@ while [ "$QUIT" == "0" ]; do echo "[$OPTION_NUM] Exit Script" OPTIONS[$OPTION_NUM]="quit" echo "" - echo -n "Option: " - read our_entry - echo "" - ${OPTIONS[our_entry]} ${our_entry} + read -p "Option: " our_entry + [ $? -eq 0 ] || exit 0 + + numeric="^[[:digit:]]+$" + if [[ "$our_entry" =~ $numeric ]]; then + ${OPTIONS[our_entry]} ${our_entry} + else + echo "Please enter a numeric value" + fi if [ "$QUIT" == "0" ] ; then echo