network: code optimization for speed and removal/cornering of obsolete functions

This commit is contained in:
Silvan Calarco 2013-09-18 20:10:00 +02:00
parent 57701f3c38
commit 94b6db3676

View File

@ -15,9 +15,6 @@ me="network"
. /etc/postplug/postplug.defs . /etc/postplug/postplug.defs
postplugnew_file=$postplugnewdir/network
rm -f $postplugnew_file
[ -r /etc/sysconfig/postplug ] && . /etc/sysconfig/postplug [ -r /etc/sysconfig/postplug ] && . /etc/sysconfig/postplug
[ -r /etc/sysconfig/rc ] && . /etc/sysconfig/rc [ -r /etc/sysconfig/rc ] && . /etc/sysconfig/rc
@ -66,7 +63,7 @@ function cdc_usb() {
ifconfig usb0 &>/dev/null && { ifconfig usb0 &>/dev/null && {
[ "$NETWORK_CDC_NETMASK" ] && CDC_NETMASK=$NETWORK_CDC_NETMASK [ "$NETWORK_CDC_NETMASK" ] && CDC_NETMASK=$NETWORK_CDC_NETMASK
[ -e $network_devices/ifcng-usb0 ] || { [ -e $network_devices/ifcfg-usb0 ] || {
[ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR [ "$NETWORK_CDC_IPADDR" ] && CDC_IPADDR=$NETWORK_CDC_IPADDR
cat > $network_devices/ifcfg-usb0 << _EOF cat > $network_devices/ifcfg-usb0 << _EOF
DEVICE=usb0 DEVICE=usb0
@ -144,28 +141,37 @@ _EOF
[ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb [ "$NETWORK_CDC_DISABLE" = "1" ] || cdc_usb
[ "$NETWORK_ANDROID_DISABLE" = "1" ] || android_usb [ "$NETWORK_ANDROID_DISABLE" = "1" ] || android_usb
# Disable p2p interface managed by NetworkManager
for net_int in $(cat /proc/net/dev | sed -n '/p2p[0-9]*:/{s,:.*,,;p}'); do
# found interface already configured
[ -e $network_devices/ifcfg-${net_int} ] && continue
if [ "${net_int:0:3}" = "p2p" ]; then
P2P_HWADDR=`ifconfig $net_int | grep HWaddr | sed "s|.* HWaddr ||"`
cat > $network_devices/ifcfg-${net_int} << _EOF
DEVICE=$net_int
HWADDR=$P2P_HWADDR
ONBOOT=no
NM_CONTROLLED=no
_EOF
fi
done
# INFO: the following code is going obsolete
if [ "$NETWORK_NEWDEVICE" -a "$NETWORK_NEWDEVICE" != "off" ]; then
wlan_ints=() wlan_ints=()
for wlan_int in $(cat /proc/net/wireless 2>/dev/null | sed -n '/[a-z]*[0-9]*:/{s,:.*,,;p}'); do for wlan_int in $(cat /proc/net/wireless 2>/dev/null | sed -n '/[a-z]*[0-9]*:/{s,:.*,,;p}'); do
# checks for existing physical interfaces
/sbin/ifconfig $wlan_int >/dev/null 2>&1 || continue
# found interface already configured # found interface already configured
[ -e $network_devices/ifcfg-$wlan_int ] && continue [ -e $network_devices/ifcfg-$wlan_int ] && continue
wlan_ints[${#wlan_ints[*]}]="$wlan_int" wlan_ints[${#wlan_ints[*]}]="$wlan_int"
echo "$wlan_int" >> $postplugnew_file 2>/dev/null
done done
eth_ints=() eth_ints=()
for eth_int in $(cat /proc/net/dev | sed -n '/eth[0-9]*:/{s,:.*,,;p}'); do for eth_int in $(cat /proc/net/dev | sed -n '/eth[0-9]*:/{s,:.*,,;p}'); do
# checks for existing physical interfaces
/sbin/ifconfig $eth_int >/dev/null 2>&1 || continue
# found interface already configured # found interface already configured
[ -e $network_devices/ifcfg-$eth_int ] && continue [ -e $network_devices/ifcfg-$eth_int ] && continue
eth_ints[${#eth_ints[*]}]="$eth_int" eth_ints[${#eth_ints[*]}]="$eth_int"
echo "$eth_int" >> $postplugnew_file 2>/dev/null
done done
# how many interface have been configured? # how many interface have been configured?
@ -201,5 +207,6 @@ if [ ${#wlan_ints[*]} -gt 0 ]; then
;; ;;
esac esac
fi fi
fi
exit 0 exit 0