# # Common functions used by pktgen scripts # - Depending on bash 3 (or higher) syntax # # Author: Jesper Dangaaard Brouer # License: GPL ## -- General shell logging cmds -- function err() { local exitcode=$1 shift echo "ERROR: $@" >&2 exit $exitcode } function warn() { echo "WARN : $@" >&2 } function info() { if [[ -n "$VERBOSE" ]]; then echo "INFO : $@" >&2 fi } ## -- Pktgen proc config commands -- ## export PROC_DIR=/proc/net/pktgen # # Three different shell functions for configuring the different # components of pktgen: # pg_ctrl(), pg_thread() and pg_set(). # # These functions correspond to pktgens different components. # * pg_ctrl() control "pgctrl" (/proc/net/pktgen/pgctrl) # * pg_thread() control the kernel threads and binding to devices # * pg_set() control setup of individual devices function pg_ctrl() { local proc_file="pgctrl" proc_cmd ${proc_file} "$@" } function pg_thread() { local thread=$1 local proc_file="kpktgend_${thread}" shift proc_cmd ${proc_file} "$@" } function pg_set() { local dev=$1 local proc_file="$dev" shift proc_cmd ${proc_file} "$@" } # More generic replacement for pgset(), that does not depend on global # variable for proc file. function proc_cmd() { local result local proc_file=$1 # after shift, the remaining args are contained in $@ shift local proc_ctrl=${PROC_DIR}/$proc_file if [[ ! -e "$proc_ctrl" ]]; then err 3 "proc file:$proc_ctrl does not exists (dev added to thread?)" else if [[ ! -w "$proc_ctrl" ]]; then err 4 "proc file:$proc_ctrl not writable, not root?!" fi fi if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $@ > $proc_ctrl" fi # Quoting of "$@" is important for space expansion echo "$@" > "$proc_ctrl" local status=$? result=$(grep "Result: OK:" $proc_ctrl) # Due to pgctrl, cannot use exit code $? from grep if [[ "$result" == "" ]]; then grep "Result:" $proc_ctrl >&2 fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\"" fi } # Old obsolete "pgset" function, with slightly improved err handling function pgset() { local result if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $1 > $PGDEV" fi echo $1 > $PGDEV local status=$? result=`cat $PGDEV | fgrep "Result: OK:"` if [[ "$result" == "" ]]; then cat $PGDEV | fgrep Result: fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$1 > $PGDEV\"" fi } ## -- General shell tricks -- function root_check_run_with_sudo() { # Trick so, program can be run as normal user, will just use "sudo" # call as root_check_run_as_sudo "$@" if [ "$EUID" -ne 0 ]; then if [ -x $0 ]; then # Directly executable use sudo info "Not root, running with sudo" sudo "$0" "$@" exit $? fi err 4 "cannot perform sudo run of $0" fi } thod='get'>
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2017-02-02 13:32:10 +0100
committerDavid S. Miller <davem@davemloft.net>2017-02-03 11:13:00 -0500
commit3808d34838184fd29088d6b3a364ba2f1c018fb6 (patch)
treeb702043c49213aad979363bcc354fcd613af0cc9 /net/core
parent013e8167899d389075160412a8c0c5e0581e1f13 (diff)
ethtool: do not vzalloc(0) on registers dump
If ->get_regs_len() callback return 0, we allocate 0 bytes of memory, what print ugly warning in dmesg, which can be found further below. This happen on mac80211 devices where ieee80211_get_regs_len() just return 0 and driver only fills ethtool_regs structure and actually do not provide any dump. However I assume this can happen on other drivers i.e. when for some devices driver provide regs dump and for others do not. Hence preventing to to print warning in ethtool code seems to be reasonable. ethtool: vmalloc: allocation failure: 0 bytes, mode:0x24080c2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO) <snip> Call Trace: [<ffffffff813bde47>] dump_stack+0x63/0x8c [<ffffffff811b0a1f>] warn_alloc+0x13f/0x170 [<ffffffff811f0476>] __vmalloc_node_range+0x1e6/0x2c0 [<ffffffff811f0874>] vzalloc+0x54/0x60 [<ffffffff8169986c>] dev_ethtool+0xb4c/0x1b30 [<ffffffff816adbb1>] dev_ioctl+0x181/0x520 [<ffffffff816714d2>] sock_do_ioctl+0x42/0x50 <snip> Mem-Info: active_anon:435809 inactive_anon:173951 isolated_anon:0 active_file:835822 inactive_file:196932 isolated_file:0 unevictable:0 dirty:8 writeback:0 unstable:0 slab_reclaimable:157732 slab_unreclaimable:10022 mapped:83042 shmem:306356 pagetables:9507 bounce:0 free:130041 free_pcp:1080 free_cma:0 Node 0 active_anon:1743236kB inactive_anon:695804kB active_file:3343288kB inactive_file:787728kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:332168kB dirty:32kB writeback:0kB shmem:0kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 1225424kB writeback_tmp:0kB unstable:0kB pages_scanned:0 all_unreclaimable? no Node 0 DMA free:15900kB min:136kB low:168kB high:200kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15984kB managed:15900kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB lowmem_reserve[]: 0 3187 7643 7643 Node 0 DMA32 free:419732kB min:28124kB low:35152kB high:42180kB active_anon:541180kB inactive_anon:248988kB active_file:1466388kB inactive_file:389632kB unevictable:0kB writepending:0kB present:3370280kB managed:3290932kB mlocked:0kB slab_reclaimable:217184kB slab_unreclaimable:4180kB kernel_stack:160kB pagetables:984kB bounce:0kB free_pcp:2236kB local_pcp:660kB free_cma:0kB lowmem_reserve[]: 0 0 4456 4456 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/ethtool.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c