aboutsummaryrefslogtreecommitdiffstats
path: root/network-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'network-scripts')
-rwxr-xr-x[-rw-r--r--]network-scripts/ifcfg-lo0
-rwxr-xr-xnetwork-scripts/ifdown4
-rwxr-xr-xnetwork-scripts/ifdown-bnep2
-rwxr-xr-xnetwork-scripts/ifdown-eth39
-rw-r--r--[-rwxr-xr-x]network-scripts/ifdown-ipv60
-rwxr-xr-xnetwork-scripts/ifdown-post6
-rw-r--r--[-rwxr-xr-x]network-scripts/ifdown-sit0
-rwxr-xr-xnetwork-scripts/ifdown-tunnel2
-rwxr-xr-xnetwork-scripts/ifup-bnep2
-rwxr-xr-xnetwork-scripts/ifup-eth223
-rw-r--r--[-rwxr-xr-x]network-scripts/ifup-ipv63
-rw-r--r--[-rwxr-xr-x]network-scripts/ifup-plusb0
-rwxr-xr-xnetwork-scripts/ifup-post8
-rw-r--r--[-rwxr-xr-x]network-scripts/ifup-sit3
-rwxr-xr-xnetwork-scripts/ifup-tunnel1
-rw-r--r--[-rwxr-xr-x]network-scripts/ifup-wireless191
-rwxr-xr-x[-rw-r--r--]network-scripts/network-functions43
17 files changed, 472 insertions, 55 deletions
diff --git a/network-scripts/ifcfg-lo b/network-scripts/ifcfg-lo
index cb4f3f94..cb4f3f94 100644..100755
--- a/network-scripts/ifcfg-lo
+++ b/network-scripts/ifcfg-lo
diff --git a/network-scripts/ifdown b/network-scripts/ifdown
index ceba9bab..72cc49d5 100755
--- a/network-scripts/ifdown
+++ b/network-scripts/ifdown
@@ -7,7 +7,7 @@ unset WINDOW # defined by screen, conflicts with our usage
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=$1
@@ -58,6 +58,8 @@ if is_true "$_use_nm"; then
fi
exit 0
fi
+ echo $"$0: interface ${CONFIG} is controlled by NetworkManager; skipping." >&2
+ exit 0
fi
if [ -x /sbin/ifdown-pre-local ]; then
diff --git a/network-scripts/ifdown-bnep b/network-scripts/ifdown-bnep
index 9b2d385d..59201fd9 100755
--- a/network-scripts/ifdown-bnep
+++ b/network-scripts/ifdown-bnep
@@ -5,7 +5,7 @@
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=${1}
diff --git a/network-scripts/ifdown-eth b/network-scripts/ifdown-eth
index 7b457e85..d7ce103a 100755
--- a/network-scripts/ifdown-eth
+++ b/network-scripts/ifdown-eth
@@ -20,9 +20,12 @@
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=${1}
+boot=$2
+daemon=
+[ "foo${boot}" = "fooboot" -o "foo${boot}" = "foodaemon" ] && daemon=1
source_config
@@ -84,6 +87,10 @@ if is_bonding_device ${DEVICE} ; then
fi
/etc/sysconfig/network-scripts/ifdown-ipv6 ${CONFIG}
+if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -f /var/run/dhcp6c_${DEVICE}.pid ]; then
+ kill $(cat /var/run/dhcp6c_${DEVICE}.pid);
+ rm -f /var/run/dhcp6c_${DEVICE}.pid;
+fi
retcode=0
@@ -106,6 +113,29 @@ for VER in "" 6 ; do
fi
done
+# Kill running dhcp client if present (supports more clients than the above)
+dhcp_client_pids() {
+ CLIENTS='dhcpcd|pump|dhcpxd|dhclient|zcip'
+ [ -n "${daemon}" -o "$MII_NOT_SUPPORTED" = "yes" ] && CLIENTS="${CLIENTS}|wpa_supplicant"
+ ps xw | egrep "${CLIENTS}" | grep ${DEVICE} | awk '{print $1;}'
+}
+
+if [ -n "${daemon}" -a "$MII_NOT_SUPPORTED" != "yes" ]; then
+ # use ifplugd -k -W to wait for it to be killed
+ /sbin/ifplugd -k -W -i ${DEVICE}
+fi
+
+pids=`dhcp_client_pids`
+if [ -n "$pids" ]; then
+ kill $pids
+ retcode=$?
+ waited=0
+ while ! dhcp_client_pids > /dev/null && [ "$waited" -lt 50 ] ; do
+ usleep 10000
+ waited=$(($waited+1))
+ done
+fi
+
# we can't just delete the configured address because that address
# may have been changed in the config file since the device was
# brought up. Flush all addresses associated with this
@@ -129,6 +159,11 @@ if [ -d "/sys/class/net/${REALDEVICE}" ]; then
echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null
fi
+ # Remove ip addresses from kernel
+ for ip in `ip addr show | egrep ${DEVICE}\$ | grep inet | awk '{print $2;}'`; do
+ ip addr del $ip dev ${DEVICE}
+ done
+
if [ "${REALDEVICE}" = "${DEVICE}" ]; then
ip link set dev ${DEVICE} down 2>/dev/null
fi
@@ -163,7 +198,7 @@ while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do
done
# don't leave an outdated key sitting around
-if [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then
+if [ -z "$IN_HOTPLUG" ] && [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then
/sbin/iwconfig ${DEVICE} enc 0 >/dev/null 2>&1
fi
diff --git a/network-scripts/ifdown-ipv6 b/network-scripts/ifdown-ipv6
index 5bc08d31..5bc08d31 100755..100644
--- a/network-scripts/ifdown-ipv6
+++ b/network-scripts/ifdown-ipv6
diff --git a/network-scripts/ifdown-post b/network-scripts/ifdown-post
index 334cdaeb..4cf6aa61 100755
--- a/network-scripts/ifdown-post
+++ b/network-scripts/ifdown-post
@@ -62,6 +62,12 @@ if [ "${REALDEVICE}" != "lo" ]; then
> /dev/null 2>&1
fi
+mdv-network-event interface_down ${DEVICE}
+
+if [ -d /etc/sysconfig/network-scripts/ifdown.d -a -x /usr/bin/run-parts ]; then
+ /usr/bin/run-parts --arg ${DEVICE} /etc/sysconfig/network-scripts/ifdown.d
+fi
+
if [ -x /sbin/ifdown-local ]; then
/sbin/ifdown-local ${DEVICE}
fi
diff --git a/network-scripts/ifdown-sit b/network-scripts/ifdown-sit
index 4a9335a5..4a9335a5 100755..100644
--- a/network-scripts/ifdown-sit
+++ b/network-scripts/ifdown-sit
diff --git a/network-scripts/ifdown-tunnel b/network-scripts/ifdown-tunnel
index a5384b18..d2ac6922 100755
--- a/network-scripts/ifdown-tunnel
+++ b/network-scripts/ifdown-tunnel
@@ -25,7 +25,7 @@
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=$1
need_config "$CONFIG"
diff --git a/network-scripts/ifup-bnep b/network-scripts/ifup-bnep
index 019e741b..5650b092 100755
--- a/network-scripts/ifup-bnep
+++ b/network-scripts/ifup-bnep
@@ -5,7 +5,7 @@
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=${1}
diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth
index 178b5173..63387733 100755
--- a/network-scripts/ifup-eth
+++ b/network-scripts/ifup-eth
@@ -15,14 +15,20 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+TEXTDOMAIN=initscripts
+
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
CONFIG=${1}
+boot=${2}
+daemon=
+[ "foo${boot}" = "fooboot" -o "foo${boot}" = "foodaemon" ] && daemon=1
need_config "${CONFIG}"
@@ -30,6 +36,7 @@ source_config
if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then
DYNCONFIG=true
+ [ "${BOOTPROTO}" = bootp ] && DHCP_CLIENT=/sbin/pump
fi
# load the module associated with that device
@@ -41,6 +48,7 @@ if [ -n "${HWADDR}" ]; then
FOUNDMACADDR=$(get_hwaddr ${REALDEVICE})
if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then
net_log $"Device ${DEVICE} has different MAC address than expected, ignoring."
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
fi
@@ -124,9 +132,67 @@ is_available_wait ${REALDEVICE} ${DEVTIMEOUT} || {
else
net_log $"Device ${DEVICE} does not seem to be present, delaying initialization."
fi
+ mdv-network-event connection_failure ${DEVICE}
exit 1
}
+# is the device wireless? If so, configure wireless device specifics
+IS_WIRELESS=
+if is_wireless_device ${DEVICE}; then
+ # ralink devices need to be up for wireless-tools to work
+ ip link set dev ${DEVICE} up
+ if [ -n "${daemon}" -o "$MII_NOT_SUPPORTED" = "yes" ]; then
+ # try to trigger association (and always load wireless settings)
+ WIRELESS_CONFIG="wireless.d/$WIRELESS_ESSID"
+ [ -f "$WIRELESS_CONFIG" ] && source "$WIRELESS_CONFIG"
+ . ./ifup-wireless
+ if [ -n "$WIRELESS_WPA_DRIVER" -a -x /usr/sbin/wpa_supplicant -a -f /etc/wpa_supplicant.conf ]; then
+ if wpa_cli -i${DEVICE} status &>/dev/null; then
+ echo "Another wpa_supplicant instance is already running for device $DEVICE"
+ else
+ /usr/sbin/wpa_supplicant -B -i ${DEVICE} \
+ -c /etc/wpa_supplicant.conf \
+ -D ${WIRELESS_WPA_DRIVER}
+ fi
+ if [ "$WIRELESS_WPA_REASSOCIATE" = "yes" ]; then
+ sleep 2
+ wpa_cli reassociate
+ fi
+ fi
+ elif [ -n "$WIRELESS_WPA_DRIVER" ]; then
+ # roaming enabled, on association
+ # source interface parameters related to current ESSID or AP if any
+ WIRELESS_CURRENT_ESSID=`iwgetid -r ${DEVICE}`
+ if [ -n "$WIRELESS_CURRENT_ESSID" ]; then
+ WIRELESS_CONFIG="wireless.d/$WIRELESS_CURRENT_ESSID"
+ if [ ! -f "$WIRELESS_CONFIG" ]; then
+ WIRELESS_CURRENT_AP=`iwgetid -r -a ${DEVICE}`
+ WIRELESS_CONFIG="wireless.d/$WIRELESS_CURRENT_AP"
+ fi
+ if [ -f "$WIRELESS_CONFIG" ]; then
+ source "$WIRELESS_CONFIG"
+ else
+ echo "Wireless device $DEVICE is associated with $WIRELESS_CURRENT_ESSID but configuration is missing"
+ fi
+ else
+ echo "Wireless device $DEVICE is configured with a roaming daemon but isn't associated"
+ fi
+ fi
+ IS_WIRELESS=1
+fi
+
+# DVB Card
+if [ -n "${DVB_ADAPTER_ID}" -a -n "${DVB_NETWORK_DEMUX}" -a -n "${DVB_NETWORK_PID}" ]; then
+ dvbnet -a ${DVB_ADAPTER_ID} -n ${DVB_NETWORK_DEMUX} -p ${DVB_NETWORK_PID}
+fi
+
+# ATMARP protocol support, enabled if ATM_ADDR is defined (VCI.VPI)
+# useful for modems using the atm kernel module (e.g. Speedtouch)
+# and ISP using "RFC 1483 Routed VC MUX" (e.g. Free Degroupe)
+if [ -n "${ATM_ADDR}" -a -x /usr/sbin/atmarpd -a -x /usr/sbin/atmarp ]; then
+ pidof atmarpd >/dev/null 2>&1 || /usr/sbin/atmarpd -b -l syslog >/dev/null 2>&1
+ atmarp -c ${DEVICE} 2>/dev/null
+fi
# this isn't the same as the MAC in the configuration filename. It is
# available as a configuration option in the config file, forcing the kernel
@@ -138,9 +204,6 @@ if [ -n "${MTU}" ]; then
ip link set dev ${DEVICE} mtu ${MTU}
fi
-# is the device wireless? If so, configure wireless device specifics
-is_wireless_device ${DEVICE} && . ./ifup-wireless
-
# Team slave device?
if [ -n "${TEAM_MASTER}" ] && [ ! "${DEVICETYPE}" = "TeamPort" ] && [ -x ./ifup-TeamPort ]; then
./ifup-TeamPort ${CONFIG} $2
@@ -204,37 +267,155 @@ if [ -n "${BRIDGE}" ]; then
exit 0
fi
-if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then
- if is_true "${PERSISTENT_DHCLIENT}"; then
- ONESHOT="";
+# exec ifplugd daemon at boot if supported
+if [ -n "${daemon}" -a "$MII_NOT_SUPPORTED" != "yes" ]; then
+ IFPLUGD_ARGS="${IFPLUGD_ARGS=-I -b}"
+ exec /sbin/ifplugd $IFPLUGD_ARGS -i $DEVICE
+fi
+
+
+BLURB="# temporary ifup addition"
+
+if [ -n "$DYNCONFIG" -a "XXX$DHCP_CLIENT" = "XXX" ];then
+ if [ -x /sbin/dhclient ];then
+ DHCP_CLIENT=/sbin/dhclient
+ # Remove any temporary references which were previously added to dhclient config
+ if [ -w /etc/dhclient-${DEVICE}.conf -a -x /sbin/dhclient ] ; then
+ grep -v "$BLURB" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null
+ cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf
+ rm -f /etc/dhclient-${DEVICE}.conf.ifupnew
+ fi
+ elif [ -x /sbin/dhcpcd ];then
+ DHCP_CLIENT=/sbin/dhcpcd
+ elif [ -x /sbin/pump ];then
+ DHCP_CLIENT=/sbin/pump
+ elif [ -x /sbin/dhcpxd ];then
+ DHCP_CLIENT=/sbin/dhcpxd
else
- ONESHOT="-1";
- fi;
+ echo $"Can't find a dhcp client"
+ mdv-network-event connection_failure ${DEVICE}
+ exit 1;
+ fi
+fi
+
+if [ "$DHCP_HOSTNAME" ] && [ "$DOMAINNAME" ]
+then
+ DHCP_HOSTNAME=`echo $DHCP_HOSTNAME | sed -e "s/\.$DOMAINNAME//g"`
+fi
+
+DHCP_ARGS=
+if [ "XXX$DHCP_CLIENT" != "XXX" ];then
+case $(basename $DHCP_CLIENT) in
+ dhcpcd)
+ DHCP_ARGS="--waitip"
+ [ -n "${DHCP_HOSTNAME}" ] && DHCP_ARGS="${DHCP_ARGS} -h ${DHCP_HOSTNAME}"
+ [ "${PEERDNS}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -C resolv.conf"
+ [ "${PEERGATEWAY}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -G"
+ [ -n "${DHCP_TIMEOUT}" ] && DHCP_ARGS="${DHCP_ARGS} -t ${DHCP_TIMEOUT}"
+ [ "${NEEDHOSTNAME}" = "no" ] && DHCP_ARGS="${DHCP_ARGS} -C lookup-hostname"
+ if [ "${PEERNTPD}" = "yes" ]; then
+ DHCP_ARGS="${DHCP_ARGS} -o ntp_servers"
+ else
+ DHCP_ARGS="${DHCP_ARGS} -C ntp.conf -O ntp_servers"
+ fi
+ if [ "${PEERYP}" = "yes" ]; then
+ DHCP_ARGS="${DHCP_ARGS} -o nis_domain -o nis_servers"
+ else
+ DHCP_ARGS="${DHCP_ARGS} -C yp.conf -C ypbind -O nis_domain -O nis_servers"
+ fi
+
+ DHCP_ARGS="${DHCP_ARGS} ${DEVICE}"
+ PIDF=/var/run/dhcpcd-${DEVICE}.pid
+ if [[ -f ${PIDF} ]]; then
+ PID=$(cat ${PIDF})
+ if [[ -n ${PID} ]]; then
+ echo "dhcpcd is running, ifdown the interface first"
+ exit;
+ fi
+ /bin/rm -f ${PIDF}; #clear it
+ fi
+ ;;
+ pump)
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
+ [ "${NEEDHOSTNAME}" = "yes" ] && DHCP_ARGS="$DHCP_ARGS --lookup-hostname"
+ [ "${PEERDNS}" = "no" ] && DHCP_ARGS="$DHCP_ARGS -d"
+ [ "${PEERGATEWAY}" = "no" ] && DHCP_ARGS="$DHCP_ARGS --no-gateway"
+ DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
+ ;;
+ dhcpxd)
+ # dhcpxd don't support NEEDHOSTNAME, PEERGATEWAY
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $HOSTNAME"
+ DHCP_ARGS="$DHCP_ARGS --wait $DEVICE"
+ ;;
+ dhclient)
+ if [[ "${PERSISTENT_DHCLIENT}" = [yY1]* ]]; then
+ ONESHOT=
+ else
+ ONESHOT="-1"
+ fi
generate_config_file_name
generate_lease_file_name
+ DHCP_ARGS="$DHCP_ARGS $ONESHOT -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid $DEVICE"
+ if [ -n "$DHCP_HOSTNAME" ]; then
+ if [ ! -e /etc/dhclient-${DEVICE}.conf ] || ! grep -q "[^# ]*send *host-name" /etc/dhclient-${DEVICE}.conf; then
+ echo "send host-name \"${DHCP_HOSTNAME}\"; $BLURB" >> /etc/dhclient-${DEVICE}.conf
+ fi
+ fi
+ if [ -n "$DHCP_TIMEOUT" ]; then
+ if [ ! -e /etc/dhclient-${DEVICE}.conf ] || ! grep -q "[^# ]*timeout" /etc/dhclient-${DEVICE}.conf; then
+ echo "timeout $DHCP_TIMEOUT; $BLURB" >> /etc/dhclient-${DEVICE}.conf
+ fi
+ fi
+ ;;
+esac
+fi
- # Initialize the dhclient args and obtain the hostname options if needed:
- DHCLIENTARGS="${DHCLIENTARGS} ${ONESHOT} -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /run/dhclient-${DEVICE}.pid"
- set_hostname_options DHCLIENTARGS
+# Remove any temporary references which were previously added to dhclient config
+if [ -w /etc/dhclient-${DEVICE}.conf ] && [ -x /sbin/dhclient ] ; then
+ LC_ALL=C grep -v "# temporary MDK ifup addition" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.conf.ifupnew 2> /dev/null
+ cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf
+ rm -f /etc/dhclient-${DEVICE}.conf.ifupnew
+fi
+if [ -n "${DYNCONFIG}" ]; then
echo
echo -n $"Determining IP information for ${DEVICE}..."
if ! is_true "${PERSISTENT_DHCLIENT}" && check_link_down ${DEVICE}; then
echo $" failed; no link present. Check cable?"
+ ip link set dev ${DEVICE} down >/dev/null 2>&1
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
ethtool_set
- if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then
+ mdv-network-event dhcp_request ${DEVICE}
+ if $DHCP_CLIENT $DHCP_ARGS ; then
+ mdv-network-event dhcp_success ${DEVICE}
echo $" done."
dhcpipv4="good"
else
+ mdv-network-event dhcp_failure ${DEVICE}
+ # Associate a zeroconf IP address to an alias of the interface
+ if [ -x /sbin/zcip ]; then
+ mdv-network-event zcip_request ${DEVICE}
+ if /sbin/zcip -s -i $DEVICE:${ZEROCONF_ALIAS_NUMER=9}; then
+ mdv-network-event zcip_success ${DEVICE}
+ echo $" done."
+ if [ -x /etc/init.d/tmdns ]; then
+ /etc/init.d/tmdns reload > /dev/null 2>&1
+ fi
+ exit 0
+ fi
+ fi
+ mdv-network-event zcip_failure ${DEVICE}
echo $" failed."
if is_true "${IPV4_FAILURE_FATAL}"; then
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
if is_false "$IPV6INIT" || ! is_true "$DHCPV6C"; then
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
net_log "Unable to obtain IPv4 DHCP address ${DEVICE}." warning
@@ -255,6 +436,7 @@ else
if ! ip link set dev ${REALDEVICE} up ; then
net_log $"Failed to bring up ${DEVICE}."
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
@@ -274,18 +456,21 @@ else
SRC=
fi
+ if [ "${REALDEVICE}" != "lo" ]; then
# set IP address(es)
for idx in {0..256} ; do
if [ -z "${ipaddr[$idx]}" ]; then
break
fi
+
if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then
if [ "${REALDEVICE}" != "lo" ] && ! is_false "${arpcheck[$idx]}"; then
ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]})
if [ $? = 1 ]; then
ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p')
net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}."
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
fi
@@ -310,6 +495,7 @@ else
# set lifetime of address to forever
ip addr change ${ipaddr[$idx]}/${prefix[$idx]} dev ${REALDEVICE} valid_lft forever preferred_lft forever
done
+ fi
# Set a default route.
if ! is_false "${DEFROUTE}" && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then
@@ -365,6 +551,7 @@ if is_true "${DHCPV6C}" && [ -x /sbin/dhclient ]; then
echo -n $"Determining IPv6 information for ${DEVICE}..."
# Initialize the dhclient args for IPv6 and obtain the hostname options if needed:
+
if is_true "${PERSISTENT_DHCLIENT}"; then
ONESHOT="";
else
@@ -372,7 +559,15 @@ if is_true "${DHCPV6C}" && [ -x /sbin/dhclient ]; then
fi;
DHCLIENTARGS="-6 ${ONESHOT} ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /run/dhclient6-${DEVICE}.pid ${DEVICE}"
- set_hostname_options DHCLIENTARGS
+
+ # We need to wait for duplicate address detection to complete before running dhclient -6
+ for i in $(seq 5); do
+ lladdress=$(ip -6 -o a s dev "$DEVICE" scope link -tentative)
+ if [ -n "$lladdress" ]; then
+ break
+ fi
+ sleep 1
+ done
if /sbin/dhclient $DHCLIENTARGS; then
echo $" done."
diff --git a/network-scripts/ifup-ipv6 b/network-scripts/ifup-ipv6
index 55762264..f9760d06 100755..100644
--- a/network-scripts/ifup-ipv6
+++ b/network-scripts/ifup-ipv6
@@ -79,6 +79,7 @@ ipv6_test || exit 1
ipv6_test_device_status $DEVICE
if [ $? != 0 -a $? != 11 ]; then
# device doesn't exist or other problem occurs
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
@@ -180,6 +181,7 @@ if is_true "$IPV6TO4INIT"; then
if [ $? = 0 ]; then
# device is already up
net_log $"Device 'tun6to4' (from '$DEVICE') is already up, shutdown first"
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
@@ -308,6 +310,7 @@ if is_true "$IPV6TO4INIT"; then
fi
else
net_log $"6to4 configuration is not valid"
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
fi
diff --git a/network-scripts/ifup-plusb b/network-scripts/ifup-plusb
index 1b29afeb..1b29afeb 100755..100644
--- a/network-scripts/ifup-plusb
+++ b/network-scripts/ifup-plusb
diff --git a/network-scripts/ifup-post b/network-scripts/ifup-post
index 4cb986f8..008af3ff 100755
--- a/network-scripts/ifup-post
+++ b/network-scripts/ifup-post
@@ -6,7 +6,7 @@
cd /etc/sysconfig/network-scripts
. ./network-functions
-[ -f ../network ] && . ../network
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
unset REALDEVICE
if [ "$1" = --realdevice ] ; then
@@ -141,6 +141,12 @@ if [ "${REALDEVICE}" != "lo" ]; then
> /dev/null 2>&1
fi
+mdv-network-event interface_up ${DEVICE}
+
+if [ -d /etc/sysconfig/network-scripts/ifup.d -a -x /usr/bin/run-parts ]; then
+ /usr/bin/run-parts --arg ${DEVICE} /etc/sysconfig/network-scripts/ifup.d
+fi
+
if [ -x /sbin/ifup-local ]; then
/sbin/ifup-local ${DEVICE}
fi
diff --git a/network-scripts/ifup-sit b/network-scripts/ifup-sit
index 3daa3801..d29bb4d1 100755..100644
--- a/network-scripts/ifup-sit
+++ b/network-scripts/ifup-sit
@@ -56,11 +56,13 @@ ipv6_test || exit 1
# Generic tunnel device sit0 is not supported here
if [ "$DEVICE" = "sit0" ]; then
net_log $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking"
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
if [ -z "$IPV6TUNNELIPV4" ]; then
net_log $"Missing remote IPv4 address of tunnel, configuration is not valid"
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
@@ -69,6 +71,7 @@ ipv6_test_device_status $DEVICE
if [ $? = 0 ]; then
# device is already up
net_log $"Device '$DEVICE' is already up, please shutdown first"
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
diff --git a/network-scripts/ifup-tunnel b/network-scripts/ifup-tunnel
index ea85df52..d2b2b6a0 100755
--- a/network-scripts/ifup-tunnel
+++ b/network-scripts/ifup-tunnel
@@ -66,6 +66,7 @@ esac
# Generic tunnel devices are not supported here
if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 -o "$DEVICE" = ip6tnl0 ]; then
net_log $"Device '$DEVICE' isn't supported as a valid GRE device name."
+ mdv-network-event connection_failure ${DEVICE}
exit 1
fi
diff --git a/network-scripts/ifup-wireless b/network-scripts/ifup-wireless
index 702b6199..5fdceadf 100755..100644
--- a/network-scripts/ifup-wireless
+++ b/network-scripts/ifup-wireless
@@ -15,48 +15,181 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
-# Configure wireless network device options. See iw(8) for more info.
+# Configure wireless network device options. See iwconfig(8) for more info.
+# Mageia prefixes the following variables with WIRELESS_ prefix.
# Valid variables:
# MODE: Ad-Hoc, Managed, etc.
# ESSID: Name of the wireless network
+# NWID: Name of this machine on the network. Hostname is default
# FREQ: Frequency to operate on. See CHANNEL
+# CHANNEL: Numbered frequency to operate on. See FREQ
+# SENS: Sensitivity threshold for packet rejection.
+# RATE: Transfer rate. Usually one of Auto, 11, 5, 2, or 1.
+# RTS: Explicit RTS handshake. Usually not specified (auto)
+# FRAG: Fragmentation threshold to split packets. Usually not specified.
+# IWCONFIG: Extra parameters to pass directly to IWCONFIG
+# IWPRIV: Extra parameters to pass directly to IWPRIV
+#
+# redhat-only variables:
# KEY: Encryption key for WEP.
+# KEY[1-4]: Encryption key for WEP in position [1-4]
+# SECURITYMODE: Security mode, e.g: 'open' or 'restricted'
+# SPYIPS: List of IP addresses to "spy" on for link performance stats.
+#
+# mandriva-only variables:
+# WIRELESS_NICK: nickname for wireless connection
+# WIRELESS_ENC_KEY: Encryption key for WEP.
+# WIRELESS_ENC_MODE: Security mode, e.g: 'open' or 'restricted'
+# WIRELESS_XSUPPLICANT: Enabling xsupplicant support
+# WIRELESS_XSUPPLICANT_FILE: Custom location for xsupplicant.conf file
# Only meant to be called from ifup.
-cd /etc/sysconfig/network-scripts
-. ./network-functions
+# unify variables common to RH and Mageia-style ifcfg
+MODE=${MODE:-$WIRELESS_MODE}
+ESSID=${ESSID:-$WIRELESS_ESSID}
+NWID=${NWID:-$WIRELESS_NWID}
+FREQ=${FREQ:-$WIRELESS_FREQ}
+CHANNEL=${CHANNEL:-$WIRELESS_CHANNEL}
+SENS=${SENS:-$WIRELESS_SENS}
+RATE=${RATE:-$WIRELESS_RATE}
+POWER=${POWER:-$WIRELESS_POWER}
+RTS=${RTS:-$WIRELESS_RTS}
+FRAG=${FRAG:-$WIRELESS_FRAG}
+IWCONFIG=${IWCONFIG:-$WIRELESS_IWCONFIG}
+IWSPY=${IWSPY:-$WIRELESS_IWSPY}
+IWPRIV=${IWPRIV:-$WIRELESS_IWPRIV}
-IW=${IW:-iw}
+# Mode need to be first : some settings apply only in a specific mode !
+if [ -n "$MODE" ] ; then
+ # for some cards, the mode can only be set with the card is down
+ # so we bring the card down (and suspending ifplugd if it is running)
+ # in order to do so (mdv bug #43166)
+ ifplugd -S -i $DEVICE 2>/dev/null
+ /sbin/ip link set dev $DEVICE down
+ iwconfig $DEVICE mode $MODE
+ ifplugd -R -i $DEVICE 2>/dev/null
+fi
-[ "$KEY" ] && KEYS="key d:0:$KEY"
+# Set link up (some cards require this.)
+/sbin/ip link set dev ${DEVICE} up
-shopt -s nocasematch
+# Setup the card nickname
+# This is a bit hackish, but should do the job right...
+if [ -n "$ESSID" -o -n "$MODE" ] ; then
+ NICKNAME=$(/bin/hostname)
+ iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1
+fi
+if [ -n "$WIRELESS_NICK" ] ; then
+ iwconfig $DEVICE nick $WIRELESS_NICK >/dev/null 2>&1
+elif [ -n "$ESSID" ] || [ -n "$MODE" ] ; then
+ # This is a bit hackish, but should do the job right...
+ NICKNAME=`/bin/hostname`
+ iwconfig $DEVICE nick $NICKNAME >/dev/null 2>&1
+fi
-case "$MODE" in
-managed)
- if [ "$ESSID" ]; then
- $IW dev "$DEVICE" set type managed
- $IW dev "$DEVICE" connect -w "$ESSID" $FREQ $KEYS
- fi
- ;;
-ad-hoc)
- if [ -n "$ESSID" -a -n "$FREQ" ]; then
- $IW dev "$DEVICE" set type ibss
- $IW dev "$DEVICE" ibss join "$ESSID" "$FREQ" $KEYS
- fi
- ;;
-monitor)
- if [ "$FREQ" ]; then
- $IW dev "$DEVICE" set type monitor
- $IW dev "$DEVICE" set freq "$FREQ"
+# Regular stuff...
+# network id
+if [ -n "$NWID" ] ; then
+ iwconfig $DEVICE nwid $NWID
+fi
+
+# frequency and channel
+if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then
+ iwconfig $DEVICE freq $FREQ
+elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then
+ iwconfig $DEVICE channel $CHANNEL
+fi
+
+# sensitivity
+if [ -n "$SENS" ] ; then
+ iwconfig $DEVICE sens $SENS
+fi
+
+# rate
+if [ -n "$RATE" ] ; then
+ iwconfig $DEVICE rate "$RATE"
+fi
+
+# encryption
+# for redhat-style ifcfg
+if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
+ [ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1
+ [ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2
+ [ -n "$KEY3" ] && iwconfig $DEVICE key "[3]" $KEY3
+ [ -n "$KEY4" ] && iwconfig $DEVICE key "[4]" $KEY4
+ [ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key "[${DEFAULTKEY}]"
+ [ -n "$KEY" ] && iwconfig $DEVICE key $KEY
+else
+ iwconfig $DEVICE key off
+fi
+
+# for mandriva-style ifcfg
+if [ -n "$WIRELESS_ENC_KEY" -o "$WIRELESS_ENC_MODE" ] ; then
+ if [ -n "$WIRELESS_ENC_MODE" ]; then
+ iwconfig $DEVICE key $WIRELESS_ENC_MODE "$WIRELESS_ENC_KEY"
+ else
+ # compatibility for older config files
+ # that used to contain enc mode in key
+ echo "$WIRELESS_ENC_KEY" | egrep -q '^(open|restricted) '
+ if [ $? == 0 ]; then
+ iwconfig $DEVICE key $WIRELESS_ENC_KEY
+ else
+ iwconfig $DEVICE key "$WIRELESS_ENC_KEY"
+ fi
fi
- ;;
-esac
+fi
+
+# security mode
+if [ -n "$SECURITYMODE" ]; then
+ iwconfig $DEVICE enc $SECURITYMODE
+fi
+
+# power
+if [ -n "$POWER" ] ; then
+ iwconfig $DEVICE power $POWER
+fi
+
+# rts
+if [ -n "$RTS" ] ; then
+ iwconfig $DEVICE rts $RTS
+fi
+
+# fragmentation
+if [ -n "$FRAG" ] ; then
+ iwconfig $DEVICE frag $FRAG
+fi
+
+# More specific parameters passed directly to IWCONFIG
+if [ -n "$IWCONFIG" ] ; then
+ iwconfig $DEVICE $IWCONFIG
+fi
+
+# iwspy settings
+if [ -n "$SPYIPS" ] ; then
+ for IP in $SPYIPS; do
+ iwspy $DEVICE + $IP
+ done
+fi
+if [ -n "$IWSPY" ] ; then
+ /sbin/iwspy $DEVICE $IWSPY
+fi
+
+# private options
+if [ -n "$IWPRIV" ] ; then
+ IFS=$'\n' echo "$IWPRIV" | while read priv; do
+ [ -n -n "$priv" ] && eval "/sbin/iwpriv $DEVICE $priv"
+ done
+fi
-if [ -n "$WOWLAN" ] ; then
- PHYDEVICE=$(phy_wireless_device $DEVICE)
- iw phy $PHYDEVICE wowlan enable ${WOWLAN}
+# ESSID need to be last : most device re-perform the scanning/discovery
+# when this is set, and things like encryption keys are better be
+# defined if we want to discover the right set of APs/nodes.
+if [ -n "$ESSID" ] ; then
+ iwconfig $DEVICE essid "$ESSID"
+else
+ # use any essid
+ iwconfig $DEVICE essid any >/dev/null 2>&1
fi
diff --git a/network-scripts/network-functions b/network-scripts/network-functions
index 332115b8..2d95cfcf 100644..100755
--- a/network-scripts/network-functions
+++ b/network-scripts/network-functions
@@ -13,6 +13,8 @@ HOSTNAME="$(hostname)"
[ -z "$__sed_discard_ignored_files" ] && . /etc/init.d/functions
+RESOLVCONF_FLAGFILE=/var/run/resolvconf/enable-updates
+
get_hwaddr ()
{
if [ -f /sys/class/net/${1}/address ]; then
@@ -291,19 +293,28 @@ is_nm_running ()
string:"org.freedesktop.NetworkManager" >/dev/null 2>&1
}
+is_nm_device_unavailable ()
+{
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:unavailable$"
+}
+
is_nm_active ()
{
- LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$"
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$"
}
is_nm_handling ()
{
- LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
}
is_nm_device_unmanaged ()
{
- LANG=C nmcli -t --fields GENERAL dev show "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }'
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C LC_ALL=C nmcli -t --fields GENERAL dev show "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }'
}
# Sets $alias to the device module if $? != 0
@@ -441,6 +452,9 @@ set_hostname ()
/bin/rm -f $rsctmp
fi
fi
+ if [ -d /etc/sysconfig/network-scripts/hostname.d -a -x /usr/bin/run-parts ]; then
+ /usr/bin/run-parts --arg $1 /etc/sysconfig/network-scripts/hostname.d
+ fi
}
check_device_down ()
@@ -455,6 +469,9 @@ check_device_down ()
check_link_down ()
{
+ if [ "${MII_NOT_SUPPORTED}" = yes ]; then
+ return 1
+ fi
if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then
ip link set dev $1 up >/dev/null 2>&1
fi
@@ -645,14 +662,20 @@ change_resolv_conf ()
fi
n_args=$(($n_args-1))
done
- elif [ $# -eq 1 ]; then
+ elif [ $# -eq 1 -a -r "$1" ]; then
if [ "x$s" != "x" ]; then
s="$s"$'\n'$(/bin/grep -vF "$s" $1)
else
s=$(cat $1)
fi
+ else
+ return
+ fi
+ if [ -e "$RESOLVCONF_FLAGFILE" ]; then
+ echo "$s" | /sbin/resolvconf -a ${DEVICE}
+ else
+ (echo "$s" > /etc/resolv.conf) >/dev/null 2>&1;
fi
- (echo "$s" > /etc/resolv.conf) >/dev/null 2>&1;
r=$?
if [ $r -eq 0 ]; then
[ -x /sbin/restorecon ] && /sbin/restorecon /etc/resolv.conf >/dev/null 2>&1 # reset the correct context
@@ -663,6 +686,16 @@ change_resolv_conf ()
return $r
}
+clear_resolv_conf ()
+{
+ if [ -e "$RESOLVCONF_FLAGFILE" ]; then
+ /sbin/resolvconf -d ${DEVICE}
+ elif [ -f /etc/resolv.conf.save ]; then
+ change_resolv_conf /etc/resolv.conf.save
+ rm -f /etc/resolv.conf.save
+ fi
+}
+
# Logging function
#
# Usage: net_log <message> <err|warning|info> <optional file/function name>