diff options
Diffstat (limited to 'net/ifconfig.sh.Linux.in')
-rw-r--r-- | net/ifconfig.sh.Linux.in | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in index 411401da..8abc9983 100644 --- a/net/ifconfig.sh.Linux.in +++ b/net/ifconfig.sh.Linux.in @@ -24,19 +24,19 @@ _exists() _ifindex() { - local line= i=-2 - while read line; do - : $(( i += 1 )) - [ ${i} -lt 1 ] && continue - case "${line}" in - "${IFACE}:"*) echo "${i}"; return 0;; - esac - done < /proc/net/dev - - # Return the next available index - : $(( i += 1 )) - echo "${i}" - return 1 + local index=-1 + local f v + if [ -e /sys/class/net/"${IFACE}"/ifindex ]; then + index=$(cat /sys/class/net/"${IFACE}"/ifindex) + else + for f in /sys/class/net/*/ifindex ; do + v=$(cat $f) + [ $v -gt $index ] && index=$v + done + : $(( index += 1 )) + fi + echo "${index}" + return 0 } _is_wireless() |