Changeset View
Changeset View
Standalone View
Standalone View
sbin/dhclient/dhclient-script
Show All 16 Lines | |||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
# | # | ||||
# | # | ||||
ARP=/usr/sbin/arp | ARP=/usr/sbin/arp | ||||
HOSTNAME=/bin/hostname | HOSTNAME=/bin/hostname | ||||
IFCONFIG='/sbin/ifconfig -n' | IFCONFIG='/sbin/ifconfig -n' | ||||
FIB=`sysctl -qn net.my_fibnum` | |||||
tsoome: As discussed on IRC; route command already is picking this value as default; this suggests the… | |||||
LOCALHOST=127.0.0.1 | LOCALHOST=127.0.0.1 | ||||
if [ -x /usr/bin/logger ]; then | if [ -x /usr/bin/logger ]; then | ||||
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient" | LOGGER="/usr/bin/logger -s -p user.notice -t dhclient" | ||||
else | else | ||||
LOGGER=echo | LOGGER=echo | ||||
fi | fi | ||||
Show All 16 Lines | |||||
arp_flush() { | arp_flush() { | ||||
arp -an -i $interface | \ | arp -an -i $interface | \ | ||||
sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' | \ | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' | \ | ||||
sh >/dev/null 2>&1 | sh >/dev/null 2>&1 | ||||
} | } | ||||
delete_old_address() { | delete_old_address() { | ||||
eval "$IFCONFIG $interface inet -alias $old_ip_address $medium" | eval "$IFCONFIG $interface inet -alias $old_ip_address fib $FIB $medium" | ||||
} | } | ||||
add_new_address() { | add_new_address() { | ||||
eval "$IFCONFIG $interface \ | eval "$IFCONFIG $interface \ | ||||
inet $new_ip_address \ | inet $new_ip_address \ | ||||
netmask $new_subnet_mask \ | netmask $new_subnet_mask \ | ||||
broadcast $new_broadcast_address \ | broadcast $new_broadcast_address \ | ||||
fib $FIB \ | |||||
$medium" | $medium" | ||||
$LOGGER "New IP Address ($interface): $new_ip_address" | $LOGGER "New IP Address ($interface): $new_ip_address" | ||||
$LOGGER "New Subnet Mask ($interface): $new_subnet_mask" | $LOGGER "New Subnet Mask ($interface): $new_subnet_mask" | ||||
$LOGGER "New Broadcast Address ($interface): $new_broadcast_address" | $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" | ||||
$LOGGER "New Routers ($interface): $new_routers" | $LOGGER "New Routers ($interface): $new_routers" | ||||
} | } | ||||
delete_old_alias() { | delete_old_alias() { | ||||
if [ -n "$alias_ip_address" ]; then | if [ -n "$alias_ip_address" ]; then | ||||
$IFCONFIG $interface inet -alias $alias_ip_address > /dev/null 2>&1 | $IFCONFIG $interface inet -alias $alias_ip_address fib $FIB > /dev/null 2>&1 | ||||
#route delete $alias_ip_address $LOCALHOST > /dev/null 2>&1 | #route delete $alias_ip_address $LOCALHOST > /dev/null 2>&1 | ||||
fi | fi | ||||
} | } | ||||
add_new_alias() { | add_new_alias() { | ||||
if [ -n "$alias_ip_address" ]; then | if [ -n "$alias_ip_address" ]; then | ||||
$IFCONFIG $interface inet alias $alias_ip_address netmask \ | $IFCONFIG $interface inet alias $alias_ip_address netmask \ | ||||
$alias_subnet_mask | $alias_subnet_mask fib $FIB | ||||
#route add $alias_ip_address $LOCALHOST | #route add $alias_ip_address $LOCALHOST | ||||
fi | fi | ||||
} | } | ||||
fill_classless_routes() { | fill_classless_routes() { | ||||
set $1 | set $1 | ||||
while [ $# -ge 5 ]; do | while [ $# -ge 5 ]; do | ||||
if [ $1 -eq 0 ]; then | if [ $1 -eq 0 ]; then | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | add_new_routes() { | ||||
# Classless Static Routes option are provided. | # Classless Static Routes option are provided. | ||||
if [ -n "$new_classless_routes" ]; then | if [ -n "$new_classless_routes" ]; then | ||||
fill_classless_routes "$new_classless_routes" | fill_classless_routes "$new_classless_routes" | ||||
$LOGGER "New Classless Static Routes ($interface): $classless_routes" | $LOGGER "New Classless Static Routes ($interface): $classless_routes" | ||||
set $classless_routes | set $classless_routes | ||||
while [ $# -gt 1 ]; do | while [ $# -gt 1 ]; do | ||||
if [ "0.0.0.0" = "$2" ]; then | if [ "0.0.0.0" = "$2" ]; then | ||||
route add "$1" -iface "$interface" | route add "$1" -iface "$interface" -fib $FIB | ||||
else | else | ||||
route add "$1" "$2" | route add "$1" "$2" -fib $FIB | ||||
fi | fi | ||||
shift; shift | shift; shift | ||||
done | done | ||||
return | return | ||||
fi | fi | ||||
for router in $new_routers; do | for router in $new_routers; do | ||||
if is_default_interface; then | if is_default_interface; then | ||||
if [ "$new_ip_address" = "$router" ]; then | if [ "$new_ip_address" = "$router" ]; then | ||||
route add default -iface $router >/dev/null 2>&1 | route add default -iface $router -fib $FIB >/dev/null 2>&1 | ||||
else | else | ||||
route add default $router >/dev/null 2>&1 | route add default $router -fib $FIB >/dev/null 2>&1 | ||||
fi | fi | ||||
fi | fi | ||||
# 2nd and subsequent default routers error out, so explicitly | # 2nd and subsequent default routers error out, so explicitly | ||||
# stop processing the list after the first one. | # stop processing the list after the first one. | ||||
break | break | ||||
done | done | ||||
if [ -n "$new_static_routes" ]; then | if [ -n "$new_static_routes" ]; then | ||||
$LOGGER "New Static Routes ($interface): $new_static_routes" | $LOGGER "New Static Routes ($interface): $new_static_routes" | ||||
set $new_static_routes | set $new_static_routes | ||||
while [ $# -gt 1 ]; do | while [ $# -gt 1 ]; do | ||||
route add $1 $2 | route add $1 $2 -fib $FIB | ||||
shift; shift | shift; shift | ||||
done | done | ||||
fi | fi | ||||
} | } | ||||
add_new_resolv_conf() { | add_new_resolv_conf() { | ||||
# XXX Old code did not create/update resolv.conf unless both | # XXX Old code did not create/update resolv.conf unless both | ||||
# $new_domain_name and $new_domain_name_servers were provided. PR | # $new_domain_name and $new_domain_name_servers were provided. PR | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | if [ -f /etc/dhclient-enter-hooks ]; then | ||||
fi | fi | ||||
fi | fi | ||||
: ${resolvconf_enable="YES"} | : ${resolvconf_enable="YES"} | ||||
case $reason in | case $reason in | ||||
MEDIUM) | MEDIUM) | ||||
eval "$IFCONFIG $interface $medium" | eval "$IFCONFIG $interface $medium" | ||||
eval "$IFCONFIG $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1 | eval "$IFCONFIG $interface inet -alias 0.0.0.0 fib $FIB $medium" >/dev/null 2>&1 | ||||
sleep 1 | sleep 1 | ||||
;; | ;; | ||||
PREINIT) | PREINIT) | ||||
delete_old_alias | delete_old_alias | ||||
$IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 up | $IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 fib $FIB up | ||||
;; | ;; | ||||
ARPCHECK|ARPSEND) | ARPCHECK|ARPSEND) | ||||
;; | ;; | ||||
BOUND|RENEW|REBIND|REBOOT) | BOUND|RENEW|REBIND|REBOOT) | ||||
check_hostname | check_hostname | ||||
if [ -n "$old_ip_address" ]; then | if [ -n "$old_ip_address" ]; then | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if ping -q -c 1 -t 1 "$1"; then | ||||
if ! is_default_interface; then | if ! is_default_interface; then | ||||
exit_with_hooks 0 | exit_with_hooks 0 | ||||
fi | fi | ||||
if add_new_resolv_conf; then | if add_new_resolv_conf; then | ||||
exit_with_hooks 0 | exit_with_hooks 0 | ||||
fi | fi | ||||
fi | fi | ||||
fi | fi | ||||
eval "$IFCONFIG $interface inet -alias $new_ip_address $medium" | eval "$IFCONFIG $interface inet -alias $new_ip_address fib $FIB $medium" | ||||
delete_old_routes | delete_old_routes | ||||
exit_with_hooks 1 | exit_with_hooks 1 | ||||
;; | ;; | ||||
esac | esac | ||||
exit_with_hooks 0 | exit_with_hooks 0 |
As discussed on IRC; route command already is picking this value as default; this suggests the ifconfig should do the same for consistent behavior. So, while this change does indeed fix the fib value use case, the proper fix (IMO) would be to fix ifconfig, and then this patch would not be needed.