mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-22 11:17:19 +00:00
2c615e1a64
After a change of devd.conf, devd(8) handles NIC attach/detach event by using /etc/pccard_ether with the interface name as the argument. This model does not work properly with IPv6 configuration because the implementation of IPv6 stateless auto-configuration in the FreeBSD rc.d scripts depends on whether there are any explicit configurations for interfaces or not. It works this way: if no manual configuration, it will perform auto-configuration, but otherwise no auto-configuration will be performed. So, this behavior can only be determined by all of the interfaces on a system, not a single one. For this reason, the network6_interface_setup() function called from the pccard_ether_start() does not work with a single interface name. And what is worse, this combination of devd.conf and pccard_ether_start() caused a bad side-effect that when ipv6_enable=YES, all of interfaces marked as DOWN would be UP unconditionally (and router solicitation was sent) just after devd(8) was invoked. This should be fixed in a more sophisticated way.
127 lines
2.2 KiB
Bash
Executable File
127 lines
2.2 KiB
Bash
Executable File
#!/bin/sh -
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# pccard_ether interfacename [start|stop|restart]
|
|
#
|
|
# example: pccard_ether fxp0 start
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
. /etc/network.subr
|
|
|
|
name="pccard_ether"
|
|
start_precmd="checkauto"
|
|
start_cmd="pccard_ether_start"
|
|
stop_precmd="checkauto"
|
|
stop_cmd="pccard_ether_stop"
|
|
restart_precmd="checkauto"
|
|
restart_cmd="pccard_ether_restart"
|
|
|
|
setup_routes()
|
|
{
|
|
# Add default route into $static_routes
|
|
case ${defaultrouter} in
|
|
[Nn][Oo] | '')
|
|
;;
|
|
*)
|
|
static_routes="default ${static_routes}"
|
|
route_default="default ${defaultrouter}"
|
|
;;
|
|
esac
|
|
|
|
# Add private route for this interface into $static_routes
|
|
eval ifx_routes=\$static_routes_${ifn}
|
|
if [ -n "${ifx_routes}" ]; then
|
|
static_routes="${ifx_routes} ${static_routes}"
|
|
fi
|
|
|
|
# Set up any static routes if specified
|
|
if [ -n "${static_routes}" ]; then
|
|
for i in ${static_routes}; do
|
|
eval route_args=\$route_${i}
|
|
route add ${route_args}
|
|
done
|
|
fi
|
|
}
|
|
|
|
remove_routes()
|
|
{
|
|
# Delete static route if specified
|
|
eval ifx_routes=\$static_routes_${ifn}
|
|
if [ -n "${ifx_routes}" ]; then
|
|
for i in ${ifx_routes}; do
|
|
eval route_args=\$route_${i}
|
|
route delete ${route_args}
|
|
done
|
|
fi
|
|
}
|
|
|
|
checkauto()
|
|
{
|
|
if [ -z "$rc_force" ]; then
|
|
# Ignore interfaces with the NOAUTO keyword
|
|
autoif $ifn || exit 0
|
|
fi
|
|
}
|
|
|
|
pccard_ether_start()
|
|
{
|
|
ifexists $ifn || exit 1
|
|
|
|
if [ -z "$rc_force" ]; then
|
|
for uif in `ifconfig -ul`; do
|
|
if [ "${uif}" = "${ifn}" ]; then
|
|
# Interface is already up, so ignore it.
|
|
exit 0
|
|
fi
|
|
done
|
|
fi
|
|
|
|
/etc/rc.d/netif start $ifn
|
|
|
|
# Do route configuration if needed.
|
|
# XXX: should probably do this by calling rc.d/routing.
|
|
if [ -n "`ifconfig_getargs $ifn`" ]; then
|
|
if ! dhcpif $ifn; then
|
|
setup_routes
|
|
fi
|
|
fi
|
|
|
|
# XXX: IPv6 setup should be done in some way.
|
|
}
|
|
|
|
pccard_ether_stop()
|
|
{
|
|
if [ -n "`ifconfig_getargs $ifn`" ]; then
|
|
if ! dhcpif $ifn; then
|
|
remove_routes
|
|
fi
|
|
fi
|
|
|
|
/etc/rc.d/netif stop $ifn
|
|
|
|
# clean ARP table
|
|
ifexists $ifn && arp -d -i $ifn -a
|
|
}
|
|
|
|
pccard_ether_restart()
|
|
{
|
|
# Hand implemented because the default implementation runs
|
|
# the equivalent of "$0 start; $0 stop" and this script
|
|
# doesn't support that syntax
|
|
pccard_ether_stop
|
|
pccard_ether_start
|
|
}
|
|
|
|
ifn=$1
|
|
shift
|
|
if [ -z "$*" ]; then
|
|
args="start"
|
|
else
|
|
args=$*
|
|
fi
|
|
|
|
load_rc_config pccard_ether
|
|
run_rc_command $args
|