Lines Matching +full:max +full:- +full:functions

2 # Common functions used by pktgen scripts
3 # - Depending on bash 3 (or higher) syntax
8 set -o errexit
10 ## -- General shell logging cmds --
23 if [[ -n "$VERBOSE" ]]; then
28 ## -- Pktgen proc config commands -- ##
31 # Three different shell functions for configuring the different
35 # These functions correspond to pktgens different components.
67 if [[ ! -e "$proc_ctrl" ]]; then
70 if [[ ! -w "$proc_ctrl" ]]; then
111 if [[ -z "$APPEND" ]]; then
112 if [[ $EUID -eq 0 ]]; then
118 ## -- General shell tricks --
123 if [ "$EUID" -ne 0 ]; then
124 if [ -x $0 ]; then # Directly executable use sudo
126 sudo -E "$0" "$@"
137 if [[ $node == -1 ]]; then
148 local queues="${IFACE}-.*TxRx"
150 irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:)
151 [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:)
152 [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\
153 do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\
155 [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE"
165 local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \
170 node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }`
177 function in_between() { [[ ($1 -ge $2) && ($1 -le $3) ]] ; }
185 local sep_cnt=$(tr -cd $sep <<< $1 | wc -c)
194 shrink=( $(egrep -o "$sep{2,}" <<< $addr) )
195 if [[ ${#shrink[@]} -ne 0 ]]; then
196 if [[ ${#shrink[@]} -gt 1 || ( ${shrink[0]} != $sep2 ) ]]; then
203 [[ ${addr: -1} == $sep ]] && addr=${addr}0
204 echo "${addr/$sep2/$(printf ':0%.s' $(seq $[8-sep_cnt])):}"
211 [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
214 local max=$[ 2**(len*2)-1 ]
222 if [[ -n $prefix ]]; then
230 IFS=$sep read -a addr <<< $net
237 # check each digit (0 <= $digit <= $max)
240 if ! (in_between $digit 0 $max); then
254 [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
261 if [[ -z $prefix ]]; then
272 local remain=$[ bitlen-prefix ]
275 local min max
281 IFS=$sep read -ra ip <<< $net
286 # calculate min/max ip with &,| operator
293 max[$i]=$[ 2#$ip_bit | 2#${max_mask:$idx:$octet} ]
295 max[$i]=$(printf '%X' ${max[$i]}); }
299 max_ip=$(IFS=$sep; echo "${max[*]}")
315 IFS="-" read -ra port_list <<< $port_str
318 max_port=${port_list[1]:-$min_port}
332 if [[ $min_port -le $max_port ]]; then
338 err 5 "Invalid port(s): $min_port-$max_port"