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 [[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT
113 ## -- General shell tricks --
118 if [ "$EUID" -ne 0 ]; then
119 if [ -x $0 ]; then # Directly executable use sudo
132 if [[ $node == -1 ]]; then
143 local queues="${IFACE}-.*TxRx"
145 irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:)
146 [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:)
147 [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\
148 do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\
150 [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE"
160 local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \
165 node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }`
172 function in_between() { [[ ($1 -ge $2) && ($1 -le $3) ]] ; }
180 local sep_cnt=$(tr -cd $sep <<< $1 | wc -c)
189 shrink=( $(egrep -o "$sep{2,}" <<< $addr) )
190 if [[ ${#shrink[@]} -ne 0 ]]; then
191 if [[ ${#shrink[@]} -gt 1 || ( ${shrink[0]} != $sep2 ) ]]; then
198 [[ ${addr: -1} == $sep ]] && addr=${addr}0
199 echo "${addr/$sep2/$(printf ':0%.s' $(seq $[8-sep_cnt])):}"
206 [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
209 local max=$[ 2**(len*2)-1 ]
217 if [[ -n $prefix ]]; then
225 IFS=$sep read -a addr <<< $net
232 # check each digit (0 <= $digit <= $max)
235 if ! (in_between $digit 0 $max); then
249 [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
256 if [[ -z $prefix ]]; then
267 local remain=$[ bitlen-prefix ]
270 local min max
276 IFS=$sep read -ra ip <<< $net
281 # calculate min/max ip with &,| operator
288 max[$i]=$[ 2#$ip_bit | 2#${max_mask:$idx:$octet} ]
290 max[$i]=$(printf '%X' ${max[$i]}); }
294 max_ip=$(IFS=$sep; echo "${max[*]}")
310 IFS="-" read -ra port_list <<< $port_str
313 max_port=${port_list[1]:-$min_port}
327 if [[ $min_port -le $max_port ]]; then
333 err 5 "Invalid port(s): $min_port-$max_port"