diff --git a/dhclient-script b/dhclient-script index 7fcbf9d..5008b0b 100755 --- a/dhclient-script +++ b/dhclient-script @@ -215,7 +215,7 @@ dhconfig() { [ ! "${old_ip_address}" = "${new_ip_address}" ]; then # IP address changed. Bringing down the interface will delete all # routes, and clear the ARP cache. - ip -family inet addr flush dev ${interface} + ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -family inet link set dev ${interface} down fi @@ -319,7 +319,7 @@ dhconfig() { if [ ! "${new_ip_address}" = "${alias_ip_address}" ] && [ -n "${alias_ip_address}" ]; then - ip -family inet addr flush dev ${interface}:0 + ip -family inet addr flush dev ${interface}:0 >/dev/null 2>&1 ip -family inet addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0 ip route replace ${alias_ip_address}/32 dev ${interface}:0 fi @@ -413,6 +413,15 @@ dhconfig() { fi } +get_prefix() { + ip="${1}" + nm="${2}" + + if [ -n "${ip}" -a -n "${nm}" ]; then + ipcalc -s -p ${ip} ${nm} | cut -d '=' -f 2 + fi +} + # # ### MAIN @@ -450,24 +459,13 @@ if [ -f /etc/sysconfig/networking/network ]; then . /etc/sysconfig/networking/network fi -CONFIG="${interface}" -if [ -d /etc/sysconfig/network-scripts ]; then - cd /etc/sysconfig/network-scripts - need_config ${CONFIG} - source_config >/dev/null 2>&1 -fi +CONFIG="/etc/sysconfig/network-scripts/ifcfg-${interface}" +need_config ${CONFIG} +source_config >/dev/null 2>&1 -if [ -n "${new_subnet_mask}" ]; then - new_prefix="$(ipcalc -p ${new_ip_address} ${new_subnet_mask} | cut -d '=' -f 2)" -fi - -if [ -n "${old_subnet_mask}" ]; then - old_prefix="$(ipcalc -p ${old_ip_address} ${new_subnet_mask} | cut -d '=' -f 2)" -fi - -if [ -n "${alias_subnet_mask}" ]; then - alias_prefix="$(ipcalc -p ${alias_ip_address} ${alias_subnet_mask} | cut -d '=' -f 2)" -fi +new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})" +old_prefix="$(get_prefix ${old_ip_address} ${new_subnet_mask})" +alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})" case "${reason}" in MEDIUM) @@ -484,7 +482,7 @@ case "${reason}" in if [ "${keep_old_ip}" = "yes" ]; then ip -family inet link set ${interface} up else - ip -family inet addr flush dev ${interface} + ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -family inet link set ${interface} up fi @@ -556,7 +554,7 @@ case "${reason}" in if [ -n "${old_ip_address}" ]; then # Shut down interface, which will delete routes and clear arp cache. - ip -family inet addr flush dev ${interface} + ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -family inet link set ${interface} down fi @@ -571,7 +569,7 @@ case "${reason}" in TIMEOUT) if [ -n "${new_routers}" ]; then if [ -n "${alias_ip_address}" ]; then - ip -family inet addr flush dev ${interface}:0 + ip -family inet addr flush dev ${interface}:0 >/dev/null 2>&1 fi ip -family inet addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} @@ -582,7 +580,7 @@ case "${reason}" in exit_with_hooks 0 fi - ip -family inet addr flush dev ${interface} + ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -family inet link set ${interface} down exit_with_hooks 1 else diff --git a/dhcp.spec b/dhcp.spec index 3ff0b1b..ee4d884 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -4,7 +4,7 @@ Summary: DHCP (Dynamic Host Configuration Protocol) server and relay agent Name: dhcp Version: 4.0.0 -Release: 32%{?dist} +Release: 33%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -449,6 +449,9 @@ fi %{_libdir}/libdhcp4client.so %changelog +* Wed Dec 03 2008 David Cantrell - 12:4.0.0-33 +- Do not calculate a prefix for an address we did not receive (#473885) + * Tue Nov 11 2008 David Cantrell - 12:4.0.0-32 - Correctly source ifcfg-DEVICE files (#470928) - Honor $keep_old_ip in dhclient-script (#471127)