diff options
Diffstat (limited to 'net-scripts')
-rw-r--r-- | net-scripts/net.modules.d/bonding | 13 | ||||
-rw-r--r-- | net-scripts/net.modules.d/essidnet | 5 | ||||
-rw-r--r-- | net-scripts/net.modules.d/ifplugd | 26 | ||||
-rw-r--r-- | net-scripts/net.modules.d/iwconfig | 6 | ||||
-rw-r--r-- | net-scripts/net.modules.d/netplugd | 30 | ||||
-rw-r--r-- | net-scripts/net.modules.d/vlan | 10 | ||||
-rw-r--r-- | net-scripts/net.modules.d/wpa_supplicant | 12 |
7 files changed, 48 insertions, 54 deletions
diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding index 9b93ef9..7b44a5a 100644 --- a/net-scripts/net.modules.d/bonding +++ b/net-scripts/net.modules.d/bonding @@ -17,13 +17,20 @@ bonding_depend() { # bool bonding_check_installed(void) # -# Returns 1 if ifenslave is installed, otherwise 0 +# Returns 0 if ifenslave is installed, otherwise 1 bonding_check_installed() { [[ -x /sbin/ifenslave ]] && return 0 ${1:-false} && eerror "For link aggregation (bonding) support, emerge net-misc/ifenslave" return 1 } +# bonding_exists(char *interface) +# +# Returns 0 if we are a bonded interface, otherwise 1 +bonding_exists() { + [[ -f "/proc/net/bonding/$1" ]] +} + # bool bonding_post_start(char *iface) # # Bonds the interface @@ -36,7 +43,7 @@ bonding_pre_start() { interface_exists "${iface}" true || return 1 - if [[ ! -f "/proc/net/bonding/${iface}" ]]; then + if ! bonding_exists "${iface}" ; then eerror "${iface} is not capable of bonding" return 1 fi @@ -77,7 +84,7 @@ bonding_stop() { local iface="$1" slaves s # return silently if this is not a bonding interface - [[ ! -f "/proc/net/bonding/${iface}" ]] && return 0 + ! bonding_exists "${iface}" && return 0 # don't trust the config, get the active list instead slaves=$( sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${iface}" ) diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet index 6956c31..fbb8b30 100644 --- a/net-scripts/net.modules.d/essidnet +++ b/net-scripts/net.modules.d/essidnet @@ -17,8 +17,7 @@ essidnet_depend() { before interface system after wireless installed wireless - functions wireless_check_extensions wireless_get_essid \ - wireless_get_ap_mac_address + functions wireless_exists wireless_get_essid wireless_get_ap_mac_address } # bool essidnet_start(char *iface) @@ -31,7 +30,7 @@ essidnet_depend() { essidnet_pre_start() { local iface="$1" - wireless_check_extensions "${iface}" || return 0 + wireless_exists "${iface}" || return 0 local mac=$( wireless_get_ap_mac_address "${iface}" ) local ESSID=$( wireless_get_essid "${iface}" ) diff --git a/net-scripts/net.modules.d/ifplugd b/net-scripts/net.modules.d/ifplugd index 9d4d25e..818969e 100644 --- a/net-scripts/net.modules.d/ifplugd +++ b/net-scripts/net.modules.d/ifplugd @@ -51,21 +51,15 @@ ifplugd_pre_start() { return 0 fi - # We don't work on bridges - if is_function bridge_exists ; then - if bridge_exists "${iface}"; then - veinfo "netplug does not work on bridges" - return 0 - fi - fi - - # We don't work on tun/tap interfaces - if is_function tuntap_exists ; then - if tuntap_exists "${iface}"; then - veinfo "netplug does not work on tun/tap interfaces" - return 0 + # We don't work on bonded, bridges, tun/tap, vlan or wireless + for f in bonding bridge tuntap vlan ; do + if is_function "${f}_exists" ; then + if ${f}_exists "${iface}" ; then + veinfo "ifplugd does not work with ${f}" + return 0 + fi fi - fi + done # Do some options opts="ifplugd_${ifvar}" @@ -75,8 +69,8 @@ ifplugd_pre_start() { # so via our options if [[ " ${!opts} " != *" -m wlan "* \ && " ${!opts} " != *" --api-mode=wlan "* ]]; then - if is_function wireless_check_extensions ; then - if wireless_check_extensions "${iface}"; then + if is_function wireless_exists ; then + if wireless_exists "${iface}"; then veinfo "ifplugd does not work on wireless interfaces" return 0 fi diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig index 90c0f6e..09c0c32 100644 --- a/net-scripts/net.modules.d/iwconfig +++ b/net-scripts/net.modules.d/iwconfig @@ -50,10 +50,10 @@ iwconfig_check_installed() { return 1 } -# bool iwconfig_check_extensions(char *interface) +# bool iwconfig_exists(char *interface) # # Checks to see if wireless extensions are enabled on the interface -iwconfig_check_extensions() { +iwconfig_exists() { [[ ! -e /proc/net/wireless ]] && return 1 grep -q "^[ \t]*$1:[ \t]" /proc/net/wireless } @@ -870,7 +870,7 @@ iwconfig_pre_start() { # in /proc/wireless until they are brought up. interface_up "${iface}" - if ! iwconfig_check_extensions "${iface}" ; then + if ! iwconfig_exists "${iface}" ; then veinfo "Wireless extensions not found for ${iface}" return 0 fi diff --git a/net-scripts/net.modules.d/netplugd b/net-scripts/net.modules.d/netplugd index 60bf47a..a079c3f 100644 --- a/net-scripts/net.modules.d/netplugd +++ b/net-scripts/net.modules.d/netplugd @@ -45,29 +45,15 @@ netplugd_pre_start() { return 0 fi - # We don't work on bridges - if is_function bridge_exists ; then - if bridge_exists "${iface}"; then - veinfo "netplug does not work on bridges" - return 0 + # We don't work on bonded, bridges, tun/tap, vlan or wireless + for f in bonding bridge tuntap vlan wireless ; do + if is_function "${f}_exists" ; then + if ${f}_exists "${iface}" ; then + veinfo "netplug does not work with ${f}" + return 0 + fi fi - fi - - # We don't work on tun/tap interfaces - if is_function tuntap_exists ; then - if tuntap_exists "${iface}"; then - veinfo "netplug does not work on tun/tap interfaces" - return 0 - fi - fi - - # We don't work on wirelesss interfaces - if is_function wireless_check_extensions ; then - if wireless_check_extensions "${iface}"; then - veinfo "netplug does not work on wireless interfaces" - return 0 - fi - fi + done ebegin "Starting netplug on ${iface}" diff --git a/net-scripts/net.modules.d/vlan b/net-scripts/net.modules.d/vlan index 2c6894e..e35196a 100644 --- a/net-scripts/net.modules.d/vlan +++ b/net-scripts/net.modules.d/vlan @@ -22,13 +22,21 @@ vlan_depend() { # bool vlan_check_installed(void) # -# Returns 1 if vconfig is installed, otherwise 0 +# Returns 0 if vconfig is installed, otherwise 1 vlan_check_installed() { [[ -x /sbin/vconfig ]] && return 0 ${1:-false} && eerror "For VLAN (802.1q) support, emerge net-misc/vconfig" return 1 } +# bool vlan_exists(char *interface) +# +# Returns 0 if the interface is a vlan, otherwise 1 +vlan_exists() { + [[ ! -d /proc/net/vlan ]] && return 1 + egrep -q "^$1[[:space:]]+" /proc/net/vlan/config +} + # char* vlan_get_vlans(char *interface) # # Fetch the configured vlans for an interface. Outputs a space diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index 285f06e..82157c9 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -43,10 +43,10 @@ wpa_supplicant_check_installed() { return "${installed}" } -# bool wpa_supplicant_check_extensions(char *interface) +# bool wpa_supplicant_exists(char *interface) # # Checks to see if wireless extensions are enabled on the interface -wpa_supplicant_check_extensions() { +wpa_supplicant_exists() { [[ ! -e /proc/net/wireless ]] && return 1 grep -q "^[ \t]*$1:[ \t]" /proc/net/wireless } @@ -194,7 +194,7 @@ wpa_supplicant_pre_start() { # the background unless we're not currently running if ${IN_BACKGROUND} ; then if service_started_daemon "net.${iface}" /sbin/wpa_supplicant ; then - if wpa_supplicant_check_extensions "${iface}" ; then + if wpa_supplicant_exists "${iface}" ; then ESSID=$( wpa_supplicant_get_essid "${iface}" ) ESSIDVAR=$( bash_variable "${ESSID}" ) save_options "ESSID" "${ESSID}" @@ -214,7 +214,7 @@ wpa_supplicant_pre_start() { # We only work on wirelesss interfaces unless a driver for wired # has been defined if [[ ${opts} != *" -Dwired "* && ${opts} != *" -D wired "* ]]; then - if ! wpa_supplicant_check_extensions "${iface}" ; then + if ! wpa_supplicant_exists "${iface}" ; then veinfo "wpa_supplicant only works on wireless interfaces" veinfo "unless the -D wired option is specified" return 0 @@ -234,7 +234,7 @@ wpa_supplicant_pre_start() { # This is needed for some drivers - such as hostap because they start # the card in Master mode which causes problems with wpa_supplicant. if is_function iwconfig_defaults ; then - if wpa_supplicant_check_extensions "${iface}" ; then + if wpa_supplicant_exists "${iface}" ; then iwconfig_defaults "${iface}" iwconfig_user_config "${iface}" fi @@ -317,7 +317,7 @@ wpa_supplicant_pre_start() { wpa_supplicant_associate "${iface}" || return 1 # Only report wireless info for wireless interfaces - if wpa_supplicant_check_extensions "${iface}" ; then + if wpa_supplicant_exists "${iface}" ; then # Set ESSID for essidnet and report ESSID=$( wpa_supplicant_get_essid "${iface}" ) ESSIDVAR=$( bash_variable "${ESSID}" ) |