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