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}', INTERFACE='${INTERFACE}', DEVPATH='${DEVPATH}'"
34 # Check if the udev environment variables are properly set.
37 case "${SUBSYSTEM}" in
39 PHY
="$(basename "${DEVPATH}")"
41 # Check if the PHY exists
42 if ! phy_exists
"${PHY}"; then
48 # Load regulatory domain for wireless devices
49 wireless_init_reg_domain
52 phy_leds_autoconf
"${PHY}"
56 # Propagate the hotplug event to all configured port hooks
57 hotplug_propagate_all_ports ||
exit ${EXIT_ERROR}
59 # Everything went fine
64 assert isset INTERFACE
66 # Stop processing rules for the loopback device
67 if device_is_loopback
${INTERFACE}; then
70 # Skip all pppN interfaces (for pppoe-server)
71 elif device_is_ppp
"${INTERFACE}" && [[ ${INTERFACE} =~ ^ppp
[0-9]+$
]]; then
72 log DEBUG
"Ignoring PPP device"
75 # Stop processing rules for wireless monitoring devices
76 elif device_is_wireless_monitor
${INTERFACE}; then
80 # Did we get called for a non-existing interface?
81 if ! zone_exists
"${INTERFACE}" && ! port_exists
"${INTERFACE}"; then
84 # Ignore this for some special devices
85 case "${INTERFACE}" in
86 gre0|ip6gre0|ip6tnl0|ip6_vti0|ip_vti0
)
87 log DEBUG
"Ignoring special device ${INTERFACE}"
92 log WARNING
"Got to hotplug event for a port which does not exist: ${INTERFACE}"
94 # Try to remove the device again
97 if device_is_bonding
"${INTERFACE}"; then
98 bonding_remove
"${INTERFACE}"
101 elif device_is_dummy
"${INTERFACE}"; then
102 dummy_remove
"${INTERFACE}"
105 elif device_is_wireless
"${INTERFACE}"; then
106 wireless_remove
"${INTERFACE}"
110 device_delete
"${INTERFACE}"
113 # Check if the device still exists and if so, log an error
114 if device_exists
"${INTERFACE}"; then
115 log ERROR
"Could not delete ${INTERFACE}"
123 # Don't propagate removal events for ports that don't exist
129 # Propagate the hotplug event to all configured port hooks
130 hotplug_propagate_all_ports ||
exit ${EXIT_ERROR}
132 # Propagate the hotplug event to all configured zones
133 hotplug_propagate_all_zones ||
exit ${EXIT_ERROR}
139 log ERROR
"Called for an unsupported subsystem: ${SUBSYSTEM}"
144 exit ${EXIT_NOT_HANDLED}