From 6ef16c72e9b262d695a5d2662dc1999279cc1b22 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Thu, 3 Nov 2011 23:21:54 +0000 Subject: Reduce differences in network scripts. This just merges in some upstream changes between 25 and 34 that allows for multiple static IP addresses to be defined in the ifcfg files. --- sysconfig/network-scripts/ifup-eth | 51 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'sysconfig/network-scripts/ifup-eth') diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index 93b6241e..50c1a6ab 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -443,32 +443,43 @@ else fi if [ "${REALDEVICE}" != "lo" ]; then - if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${IPADDR}/${PREFIX}" ; then - if ! /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${IPADDR} ; then - echo $"Error, some other host already uses address ${IPADDR}." - mdv-network-event connection_failure ${DEVICE} - exit 1 - fi - if ! ip addr add ${IPADDR}/${PREFIX} \ - brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then - echo $"Error adding address ${IPADDR} for ${DEVICE}." - fi - fi - - if [ -n "$SRCADDR" ]; then - sysctl -w "net.ipv4.conf.${REALDEVICE}.arp_filter=1" >/dev/null 2>&1 - fi + # 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 + [ "${REALDEVICE}" != "lo" ] && \ + if ! /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${ipaddr[$idx]} ; then + net_log $"Error, some other host already uses address ${ipaddr[$idx]}." + mdv-network-event connection_failure ${DEVICE} + exit 1 + fi + + if ! ip addr add ${ipaddr[$idx]}/${prefix[$idx]} \ + brd ${broadcast[$idx]:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then + net_log $"Error adding address ${ipaddr[$idx]} for ${DEVICE}." + fi + fi - # update ARP cache of neighboring computers - /sbin/arping -q -A -c 1 -I ${REALDEVICE} ${IPADDR} - ( sleep 2; - /sbin/arping -q -U -c 1 -I ${REALDEVICE} ${IPADDR} ) > /dev/null 2>&1 < /dev/null & + if [ -n "$SRCADDR" ]; then + sysctl -w "net.ipv4.conf.${SYSCTLDEVICE}.arp_filter=1" >/dev/null 2>&1 + fi + + # update ARP cache of neighboring computers + if [ "${REALDEVICE}" != "lo" ]; then + /sbin/arping -q -A -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} + ( sleep 2; + /sbin/arping -q -U -c 1 -I ${REALDEVICE} ${ipaddr[$idx]} ) > /dev/null 2>&1 < /dev/null & + fi + done fi # Set a default route. if [ "${DEFROUTE}" != "no" ] && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then # set up default gateway. replace if one already exists - if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${NETMASK} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then + if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then if [ -n "${ATM_ADDR}" -a -x /usr/sbin/atmarpd -a -x /usr/sbin/atmarp ]; then ip link set dev ${REALDEVICE} down ip link set dev ${REALDEVICE} up -- cgit v1.2.1