From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51BB8A04EF for ; Mon, 1 Jun 2020 10:42:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 21EAD1D177; Mon, 1 Jun 2020 10:42:03 +0200 (CEST) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id A9F5F1D177 for ; Mon, 1 Jun 2020 10:42:01 +0200 (CEST) Received: by mail-wm1-f67.google.com with SMTP id r9so9883917wmh.2 for ; Mon, 01 Jun 2020 01:42:01 -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=cokYbaWJjH90FgNM4xB/4BMZHoiHFQ7FrWLrxMx/z9k=; b=jhpnPseyRTpvBa0CtoJ6ckvleCZGfoImmWBm8P6WBExXXBYYMW4p0VQQj6oz0ClN5b kXv7LjGOg5cAzqVzyVhm9swuyYXwGgXBh/9hHI47h2IORumIKBrz2eB5YbMdHdN50Z9F b7tjiSNjuDRNVCpktnzNlbJxrq585Fd8QpCOm/5oseDQTk4U/xBRo45nK0ppWPMnjJEb UpLUDGuHq62mNHLWZvuMmH3YUY51cd8cDc1NX9aN0elVXXcdOx55eN1352xzbZdU6w/w pI1Qr+9mDgS/OEHC6TMKaHpealrtBuhRatThup3UFd/5WyAOLaOYinLXkpT2eDKckI9T VSwQ== 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=cokYbaWJjH90FgNM4xB/4BMZHoiHFQ7FrWLrxMx/z9k=; b=FBcZL6zAircb3aLStQ5bBMLBLVSMMCv6G+QBVWEciZbEu3WTtZ1S2foA0RCN3qJdqO MvXthOlH41n+jrv/xfSK/Ighj+9ZatzB1OCWoTzdROo8HSEPxBGkpR2+a320mutwlxSO kQytsA1CzYsGYNbJA2Id3Ub9gikRH++F1HFLztR8l+pdMcMd9Eu01+aHjOlHAQ+NENvX GDS8f9V63+Iy33GiWK+a+aeyZr06XkWkRnw9CY7GOnsxkSPFgmAvHpqkETp53wIgyiS5 MjGttHUWXOqbHNqtsO3BRSjlQbktucKoc4kdjVfCtJVS9xgmULSOTiPYkWJYa1LkrAOv YS9A== X-Gm-Message-State: AOAM532PvdVgrryG7AluRUmo8avBOFd7elpY6h49LBioWXXxC7MMtLB8 JzgZRygQaC5w/NzzHGTtJ3nYTA== X-Google-Smtp-Source: ABdhPJzIydvITfwLlqQI858E5JQ02UwzeorxIrL7h7w9uhoV/zWIsnB7MuuncfB0Kt02BUhEVra7lw== X-Received: by 2002:a7b:c18a:: with SMTP id y10mr21883703wmi.73.1591000921278; Mon, 01 Jun 2020 01:42:01 -0700 (PDT) Received: from localhost.localdomain ([39.40.86.239]) by smtp.gmail.com with ESMTPSA id m129sm10770276wmf.2.2020.06.01.01.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 01:42:00 -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: Mon, 1 Jun 2020 13:40:28 +0500 Message-Id: <20200601084028.20872-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200320065002.5410-1-sarosh.arif@emumba.com> References: <20200320065002.5410-1-sarosh.arif@emumba.com> Subject: [dpdk-stable] [PATCH v3] usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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-alphanumberic input. Bugzilla ID: 419 Signed-off-by: Sarosh Arif Muhammad Bilal --- usertools/dpdk-setup.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-setup.sh b/usertools/dpdk-setup.sh index e5bbe9fee..c18a6f3ee 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" @@ -595,7 +605,11 @@ while [ "$QUIT" == "0" ]; do echo -n "Option: " read our_entry echo "" - echo -n "Option: " - read our_entry + read -p "Option: " our_entry + [ $? -eq 0 ] || exit 0 + echo "" - ${OPTIONS[our_entry]} ${our_entry} - + 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 -- 2.17.1