Skip to contentSkip to conversation

usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs

PATCH Superseded Sarosh Arif 4 participants 10 messages Mar 20, 2020 – Nov 26, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20200319174423.28378

#1 lore raw

PATCH v2 1/1 usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs

Bugzilla ID: 419

---
 usertools/dpdk-setup.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
usertools/dpdk-setup.sh +10 -4
index e5bbe9fee..c27f89c5f 100755
@@ -592,11 +592,17 @@ while [ "$QUIT" == "0" ]; do
 	echo "[$OPTION_NUM] Exit Script"
 	OPTIONS[$OPTION_NUM]="quit"
 	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
 		echo -n "Press enter to continue ..."; read
Signature · 1 line
2.17.1
#2 lore raw

Hello,
If there is no objection on this patch then it can perhaps be applied.

Quoted 37 lines · Sarosh Arif

Bugzilla ID: 419

---
 usertools/dpdk-setup.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
usertools/dpdk-setup.sh +10 -5
index e5bbe9fee..c27f89c5f 100755
@@ -592,11 +592,17 @@ while [ "$QUIT" == "0" ]; do
        echo "[$OPTION_NUM] Exit Script"
        OPTIONS[$OPTION_NUM]="quit"
        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
                echo -n "Press enter to continue ..."; read
--

2.17.1

#3 lore raw

Hello,

17/04/2020 14:50, Sarosh Arif:

Quoted 2 lines

Hello,
If there is no objection on this patch then it can perhaps be applied.

There are 3 issues here:
1/ There is no maintainer for this script (and no review of the patch) 2/ There is no explanation in this patch (probably explaining the lack of review) 3/ There is a more recent patch (not a v3), probably superseding this one:

	https://patches.dpdk.org/patch/67855/
Quoted 8 lines · Sarosh Arif
Quoted 7 lines

Bugzilla ID: 419

---
 usertools/dpdk-setup.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
#4 lore raw

PATCH v3 1/1 usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs

In reply to Sarosh Arif

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

---
 usertools/dpdk-setup.sh | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
usertools/dpdk-setup.sh +20 -10
index e5bbe9fee..c18a6f3ee 100755
@@ -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

Signature · 1 line
2.17.1
#5 lore raw

PATCH v4 1/1 usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs

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

---
v4: fix signoff

---
 usertools/dpdk-setup.sh | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)
usertools/dpdk-setup.sh +26 -11
index e5bbe9fee..69cd1d2bd 100755
@@ -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
Signature · 1 line
2.17.1
#6 lore raw

Since this script has no maintainer who is responsible for providing ACK or NAK on the patches related to this script?

Quoted 87 lines · Sarosh Arif

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

---
v4: fix signoff

---
 usertools/dpdk-setup.sh | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)
usertools/dpdk-setup.sh +11 -1
index e5bbe9fee..69cd1d2bd 100755
@@ -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

usertools/dpdk-setup.sh +6 -6
-
-       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"

usertools/dpdk-setup.sh +9 -5
@@ -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
--

2.17.1

#7 lore raw
Quoted 13 lines · On Thu, 23 Jul 2020 17:13:17 +0500 Sarosh Arif <[email protected]> wrote:

Since this script has no maintainer who is responsible for providing ACK or NAK on the patches related to this script?

Quoted 8 lines · Sarosh Arif

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

If no maintainer is defined for a subtree, it should be responsiblity of the core maintainers to handle it.

PS: dpdk-setup has out grown its welcome, and a better version with a real UI is needed.

#8 lore raw

23/07/2020 19:00, Stephen Hemminger:

Quoted 17 lines
Quoted 13 lines · On Thu, 23 Jul 2020 17:13:17 +0500 Sarosh Arif <[email protected]> wrote:

Since this script has no maintainer who is responsible for providing ACK or NAK on the patches related to this script?

Quoted 8 lines · Sarosh Arif

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

Quoted 6 lines

If no maintainer is defined for a subtree, it should be responsiblity of the core maintainers to handle it.

PS: dpdk-setup has out grown its welcome, and a better version with a real UI is needed.

I don't like this script.
It works only for few cases.
I would like to remove it.

#9 lore raw
Quoted 23 lines · Thomas Monjalon

23/07/2020 19:00, Stephen Hemminger:

Quoted 21 lines
Quoted 13 lines · On Thu, 23 Jul 2020 17:13:17 +0500 Sarosh Arif <[email protected]> wrote:

Since this script has no maintainer who is responsible for providing ACK or NAK on the patches related to this script?

Quoted 8 lines · Sarosh Arif

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

If no maintainer is defined for a subtree, it should be responsiblity of the core maintainers to handle it.

Quoted 6 lines
Quoted 2 lines

PS: dpdk-setup has out grown its welcome, and a better version with a real UI is needed.

I don't like this script.
It works only for few cases.
I would like to remove it.

+1

Quoted 2 lines
#10 lore raw

24/07/2020 16:05, Jerin Jacob:

Quoted 24 lines · Thomas Monjalon
Quoted 23 lines

23/07/2020 19:00, Stephen Hemminger:

Quoted 21 lines
Quoted 13 lines · On Thu, 23 Jul 2020 17:13:17 +0500 Sarosh Arif <[email protected]> wrote:

Since this script has no maintainer who is responsible for providing ACK or NAK on the patches related to this script?

Quoted 8 lines · Sarosh Arif

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

If no maintainer is defined for a subtree, it should be responsiblity of the core maintainers to handle it.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

PS: dpdk-setup has out grown its welcome, and a better version with a real UI is needed.

I don't like this script.
It works only for few cases.
I would like to remove it.

+1

The hugepage config is now replaced with usertools/dpdk-hugepages.py