|
|
36cfb7 |
From c1aa1bc599f0ced53b5e9d21d01a03d78ae2b37f Mon Sep 17 00:00:00 2001
|
|
|
36cfb7 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
36cfb7 |
Date: Mon, 29 Apr 2019 20:05:37 +0200
|
|
|
36cfb7 |
Subject: [PATCH] examples: Some shell fixes to cbq.init
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
|
|
|
36cfb7 |
Upstream Status: iproute2.git commit 2313b6bfe4f5e
|
|
|
36cfb7 |
|
|
|
36cfb7 |
commit 2313b6bfe4f5e6b60fcdfaaeaa1eabcfd3f550f4
|
|
|
36cfb7 |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
36cfb7 |
Date: Thu Aug 17 19:09:31 2017 +0200
|
|
|
36cfb7 |
|
|
|
36cfb7 |
examples: Some shell fixes to cbq.init
|
|
|
36cfb7 |
|
|
|
36cfb7 |
This addresses the following issues:
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- $@ is an array, so don't use it in quoted strings - use $* instead.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- Add missing quotes to components of [ ] expressions. These are not
|
|
|
36cfb7 |
strictly necessary since the output of 'wc -l' should be a single word
|
|
|
36cfb7 |
only, but in case of errors, bash prints "integer expression expected"
|
|
|
36cfb7 |
instead of "too many arguments".
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- Use -print0/-0 when piping from find to xargs to allow for filenames
|
|
|
36cfb7 |
which contain whitespace.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- Quote arguments to 'eval' to prevent word-splitting.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
36cfb7 |
---
|
|
|
36cfb7 |
examples/cbq.init-v0.7.3 | 24 ++++++++++++------------
|
|
|
36cfb7 |
1 file changed, 12 insertions(+), 12 deletions(-)
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/examples/cbq.init-v0.7.3 b/examples/cbq.init-v0.7.3
|
|
|
36cfb7 |
index 1bc0d446f8983..66448d88f0053 100644
|
|
|
36cfb7 |
--- a/examples/cbq.init-v0.7.3
|
|
|
36cfb7 |
+++ b/examples/cbq.init-v0.7.3
|
|
|
36cfb7 |
@@ -532,7 +532,7 @@ cbq_off () {
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Prefixed message
|
|
|
36cfb7 |
cbq_message () {
|
|
|
36cfb7 |
- echo -e "**CBQ: $@"
|
|
|
36cfb7 |
+ echo -e "**CBQ: $*"
|
|
|
36cfb7 |
} # cbq_message
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Failure message
|
|
|
36cfb7 |
@@ -560,15 +560,15 @@ cbq_time2abs () {
|
|
|
36cfb7 |
### Display CBQ setup
|
|
|
36cfb7 |
cbq_show () {
|
|
|
36cfb7 |
for dev in `cbq_device_list`; do
|
|
|
36cfb7 |
- [ `tc qdisc show dev $dev| wc -l` -eq 0 ] && continue
|
|
|
36cfb7 |
+ [ "`tc qdisc show dev $dev| wc -l`" -eq 0 ] && continue
|
|
|
36cfb7 |
echo -e "### $dev: queueing disciplines\n"
|
|
|
36cfb7 |
tc $1 qdisc show dev $dev; echo
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- [ `tc class show dev $dev| wc -l` -eq 0 ] && continue
|
|
|
36cfb7 |
+ [ "`tc class show dev $dev| wc -l`" -eq 0 ] && continue
|
|
|
36cfb7 |
echo -e "### $dev: traffic classes\n"
|
|
|
36cfb7 |
tc $1 class show dev $dev; echo
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- [ `tc filter show dev $dev| wc -l` -eq 0 ] && continue
|
|
|
36cfb7 |
+ [ "`tc filter show dev $dev| wc -l`" -eq 0 ] && continue
|
|
|
36cfb7 |
echo -e "### $dev: filtering rules\n"
|
|
|
36cfb7 |
tc $1 filter show dev $dev; echo
|
|
|
36cfb7 |
done
|
|
|
36cfb7 |
@@ -585,7 +585,7 @@ cbq_init () {
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Gather all DEVICE fields from $1/cbq-*
|
|
|
36cfb7 |
DEVFIELDS=`find $1 -maxdepth 1 \( -type f -or -type l \) -name 'cbq-*' \
|
|
|
36cfb7 |
- -not -name '*~' | xargs sed -n 's/#.*//; \
|
|
|
36cfb7 |
+ -not -name '*~' -print0 | xargs -0 sed -n 's/#.*//; \
|
|
|
36cfb7 |
s/[[:space:]]//g; /^DEVICE=[^,]*,[^,]*\(,[^,]*\)\?/ \
|
|
|
36cfb7 |
{ s/.*=//; p; }'| sort -u`
|
|
|
36cfb7 |
[ -z "$DEVFIELDS" ] &&
|
|
|
36cfb7 |
@@ -593,7 +593,7 @@ cbq_init () {
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Check for different DEVICE fields for the same device
|
|
|
36cfb7 |
DEVICES=`echo "$DEVFIELDS"| sed 's/,.*//'| sort -u`
|
|
|
36cfb7 |
- [ `echo "$DEVICES"| wc -l` -ne `echo "$DEVFIELDS"| wc -l` ] &&
|
|
|
36cfb7 |
+ [ "`echo "$DEVICES"| wc -l`" -ne "`echo "$DEVFIELDS"| wc -l`" ] &&
|
|
|
36cfb7 |
cbq_failure "different DEVICE fields for single device!\n$DEVFIELDS"
|
|
|
36cfb7 |
} # cbq_init
|
|
|
36cfb7 |
|
|
|
36cfb7 |
@@ -618,7 +618,7 @@ cbq_load_class () {
|
|
|
36cfb7 |
PRIO_MARK=$PRIO_MARK_DEFAULT
|
|
|
36cfb7 |
PRIO_REALM=$PRIO_REALM_DEFAULT
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- eval `echo "$CFILE"| grep -E "^($CBQ_WORDS)="`
|
|
|
36cfb7 |
+ eval "`echo "$CFILE"| grep -E "^($CBQ_WORDS)="`"
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Require RATE/WEIGHT
|
|
|
36cfb7 |
[ -z "$RATE" -o -z "$WEIGHT" ] &&
|
|
|
36cfb7 |
@@ -661,7 +661,7 @@ if [ "$1" = "compile" ]; then
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### echo-only version of "tc" command
|
|
|
36cfb7 |
tc () {
|
|
|
36cfb7 |
- echo "$TC $@"
|
|
|
36cfb7 |
+ echo "$TC $*"
|
|
|
36cfb7 |
} # tc
|
|
|
36cfb7 |
|
|
|
36cfb7 |
elif [ -n "$CBQ_DEBUG" ]; then
|
|
|
36cfb7 |
@@ -669,13 +669,13 @@ elif [ -n "$CBQ_DEBUG" ]; then
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Logging version of "ip" command
|
|
|
36cfb7 |
ip () {
|
|
|
36cfb7 |
- echo -e "\n# ip $@" >> $CBQ_DEBUG
|
|
|
36cfb7 |
+ echo -e "\n# ip $*" >> $CBQ_DEBUG
|
|
|
36cfb7 |
$IP "$@" 2>&1 | tee -a $CBQ_DEBUG
|
|
|
36cfb7 |
} # ip
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### Logging version of "tc" command
|
|
|
36cfb7 |
tc () {
|
|
|
36cfb7 |
- echo -e "\n# tc $@" >> $CBQ_DEBUG
|
|
|
36cfb7 |
+ echo -e "\n# tc $*" >> $CBQ_DEBUG
|
|
|
36cfb7 |
$TC "$@" 2>&1 | tee -a $CBQ_DEBUG
|
|
|
36cfb7 |
} # tc
|
|
|
36cfb7 |
else
|
|
|
36cfb7 |
@@ -711,8 +711,8 @@ if [ "$1" != "compile" -a "$2" != "nocache" -a -z "$CBQ_DEBUG" ]; then
|
|
|
36cfb7 |
### validate the cache
|
|
|
36cfb7 |
[ "$2" = "invalidate" -o ! -f $CBQ_CACHE ] && VALID=0
|
|
|
36cfb7 |
if [ $VALID -eq 1 ]; then
|
|
|
36cfb7 |
- [ `find $CBQ_PATH -maxdepth 1 -newer $CBQ_CACHE| \
|
|
|
36cfb7 |
- wc -l` -gt 0 ] && VALID=0
|
|
|
36cfb7 |
+ [ "`find $CBQ_PATH -maxdepth 1 -newer $CBQ_CACHE| \
|
|
|
36cfb7 |
+ wc -l`" -gt 0 ] && VALID=0
|
|
|
36cfb7 |
fi
|
|
|
36cfb7 |
|
|
|
36cfb7 |
### compile the config if the cache is invalid
|
|
|
36cfb7 |
--
|
|
|
e138d9 |
2.21.0
|
|
|
36cfb7 |
|