2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 LOG_FACILITY
="network-hotplug"
27 .
/usr
/lib
/network
/functions
29 # Read network settings
32 log DEBUG
"Called with SUBSYSTEM='${SUBSYSTEM}', ACTION='${ACTION}'"
34 # Check if the udev environment variables are properly set.
37 case "${SUBSYSTEM}" in
39 PHY
="$(basename "${DEVPATH}")"
40 if phy_exists
"${PHY}"; then
41 PHY_ADDRESS
="$(phy_get_address "${PHY}")"
42 log DEBUG
" PHY='${PHY}', PHY_ADDRESS='${PHY_ADDRESS}'"
48 [ "${ACTION}" = "add" ] && phy_leds_autoconf
"${PHY}"
50 # Propagate the hotplug event to all configured port hooks
51 hotplug_propagate_all_ports ||
exit ${EXIT_ERROR}
55 assert isset INTERFACE
57 # Don't do anything for zones
58 if zone_exists
"${INTERFACE}"; then
61 # Stop processing rules for the loopback device
62 elif device_is_loopback
${INTERFACE}; then
65 # Stop processing rules for IPsec devices
66 elif device_is_ipsec
${INTERFACE}; then
69 # Stop processing rules for wireless monitoring devices
70 elif device_is_wireless_monitor
${INTERFACE}; then
74 # Get the internal type of the device for later processing
75 TYPE
="$(device_get_type "${INTERFACE}")"
77 log DEBUG
" INTERFACE='${INTERFACE}', TYPE='${TYPE}'"
79 # Handle special cases like removing automatically created
80 # devices that we don't want
81 case "${ACTION},${TYPE}" in
84 # Remove bonding devices without configuration
85 if ! port_exists
"${INTERFACE}"; then
86 bonding_remove
"${INTERFACE}"
93 # Remove the by default created dummy device
94 if [ "${INTERFACE}" = "dummy0" ]; then
95 dummy_remove
"${INTERFACE}"
102 # Create a default port for all ethernet devices
103 if ! port_exists
"${INTERFACE}"; then
104 port_new
"ethernet" "${INTERFACE}"
110 # Remove wireless devices without configuration
111 if ! port_exists
"${INTERFACE}"; then
112 wireless_remove
"${INTERFACE}"
116 # Load regulatory domain for wireless devices
117 wireless_init_reg_domain
120 # Don't propagate removal events for ports that don't exist
122 if ! port_exists
"${INTERFACE}"; then
128 if ! port_exists
"${INTERFACE}"; then
129 log ERROR
"Got to hotplug event for a port which does not exist: ${INTERFACE}"
133 # Propagate the hotplug event to all configured port hooks
134 hotplug_propagate_all_ports ||
exit ${EXIT_ERROR}
136 # Propagate the hotplug event to all configured zones
137 hotplug_propagate_all_zones ||
exit ${EXIT_ERROR}
143 log ERROR
"Called for an unsupported subsystem: ${SUBSYSTEM}"
148 exit ${EXIT_NOT_HANDLED}