Deleted Added
full compact
netif (253924) netif (256039)
1#!/bin/sh
2#
3# Copyright (c) 2003 The FreeBSD Project. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT,
18# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24#
1#!/bin/sh
2#
3# Copyright (c) 2003 The FreeBSD Project. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT,
18# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24#
25# $FreeBSD: head/etc/rc.d/netif 253924 2013-08-04 06:36:17Z hrs $
25# $FreeBSD: head/etc/rc.d/netif 256039 2013-10-04 02:44:04Z hrs $
26#
27
28# PROVIDE: netif
29# REQUIRE: atm1 FILESYSTEMS serial sppp sysctl
30# REQUIRE: ipfilter ipfs
31# KEYWORD: nojailvnet
32
33. /etc/rc.subr

--- 33 unchanged lines hidden (view full) ---

67
68 # Create cloned interfaces
69 clone_up $cmdifn
70
71 # Rename interfaces.
72 ifnet_rename $cmdifn
73
74 # Configure the interface(s).
26#
27
28# PROVIDE: netif
29# REQUIRE: atm1 FILESYSTEMS serial sppp sysctl
30# REQUIRE: ipfilter ipfs
31# KEYWORD: nojailvnet
32
33. /etc/rc.subr

--- 33 unchanged lines hidden (view full) ---

67
68 # Create cloned interfaces
69 clone_up $cmdifn
70
71 # Rename interfaces.
72 ifnet_rename $cmdifn
73
74 # Configure the interface(s).
75 network_common ifn_start
75 network_common ifn_start $cmdifn
76
77 if [ -f /etc/rc.d/ipfilter ] ; then
78 # Resync ipfilter
79 /etc/rc.d/ipfilter quietresync
80 fi
81 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
82 /etc/rc.d/bridge start $cmdifn
83 fi

--- 20 unchanged lines hidden (view full) ---

104{
105 local _if
106
107 # Set the list of interfaces to work on.
108 #
109 cmdifn=$*
110
111 # Deconfigure the interface(s)
76
77 if [ -f /etc/rc.d/ipfilter ] ; then
78 # Resync ipfilter
79 /etc/rc.d/ipfilter quietresync
80 fi
81 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
82 /etc/rc.d/bridge start $cmdifn
83 fi

--- 20 unchanged lines hidden (view full) ---

104{
105 local _if
106
107 # Set the list of interfaces to work on.
108 #
109 cmdifn=$*
110
111 # Deconfigure the interface(s)
112 network_common ifn_stop
112 network_common ifn_stop $cmdifn
113
114 # Destroy cloned interfaces
115 if [ -n "$_clone_down" ]; then
116 clone_down $cmdifn
117 fi
118
119 if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then
120 for _if in $cmdifn; do
121 /etc/rc.d/routing stop any $_if
122 done
123 fi
124}
125
126# network_common routine
127# Common configuration subroutine for network interfaces. This
128# routine takes all the preparatory steps needed for configuriing
129# an interface and then calls $routine.
130network_common()
131{
113
114 # Destroy cloned interfaces
115 if [ -n "$_clone_down" ]; then
116 clone_down $cmdifn
117 fi
118
119 if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then
120 for _if in $cmdifn; do
121 /etc/rc.d/routing stop any $_if
122 done
123 fi
124}
125
126# network_common routine
127# Common configuration subroutine for network interfaces. This
128# routine takes all the preparatory steps needed for configuriing
129# an interface and then calls $routine.
130network_common()
131{
132 local _cooked_list _fail _func _ok _str
132 local _cooked_list _tmp_list _fail _func _ok _str _cmdifn
133
134 _func=
135
136 if [ -z "$1" ]; then
137 err 1 "network_common(): No function name specified."
138 else
139 _func="$1"
133
134 _func=
135
136 if [ -z "$1" ]; then
137 err 1 "network_common(): No function name specified."
138 else
139 _func="$1"
140 shift
140 fi
141
142 # Set the scope of the command (all interfaces or just one).
143 #
144 _cooked_list=
141 fi
142
143 # Set the scope of the command (all interfaces or just one).
144 #
145 _cooked_list=
145 if [ -n "$cmdifn" ]; then
146 _tmp_list=
147 _cmdifn=$*
148 if [ -n "$_cmdifn" ]; then
146 # Don't check that the interface(s) exist. We need to run
147 # the down code even when the interface doesn't exist to
148 # kill off wpa_supplicant.
149 # XXXBED: is this really true or does wpa_supplicant die?
150 # if so, we should get rid of the devd entry
149 # Don't check that the interface(s) exist. We need to run
150 # the down code even when the interface doesn't exist to
151 # kill off wpa_supplicant.
152 # XXXBED: is this really true or does wpa_supplicant die?
153 # if so, we should get rid of the devd entry
151 _cooked_list="$cmdifn"
154 _cooked_list="$_cmdifn"
152 else
153 _cooked_list="`list_net_interfaces`"
154 fi
155
155 else
156 _cooked_list="`list_net_interfaces`"
157 fi
158
159 # Expand epair[0-9] to epair[0-9][ab].
160 for ifn in $_cooked_list; do
161 case ${ifn#epair} in
162 [0-9]*[ab]) ;; # Skip epair[0-9]*[ab].
163 [0-9]*)
164 for _str in $_cooked_list; do
165 case $_str in
166 $ifn) _tmp_list="$_tmp_list ${ifn}a ${ifn}b" ;;
167 *) _tmp_list="$_tmp_list ${ifn}" ;;
168 esac
169 done
170 _cooked_list=${_tmp_list# }
171 ;;
172 esac
173 done
174
156 _dadwait=
157 _fail=
158 _ok=
175 _dadwait=
176 _fail=
177 _ok=
159 for ifn in ${_cooked_list}; do
178 for ifn in ${_cooked_list# }; do
160 # Skip if ifn does not exist.
161 case $_func in
162 ifn_stop)
163 if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
164 warn "$ifn does not exist. Skipped."
165 _fail="${_fail} ${ifn}"
166 continue
167 fi

--- 43 unchanged lines hidden ---
179 # Skip if ifn does not exist.
180 case $_func in
181 ifn_stop)
182 if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
183 warn "$ifn does not exist. Skipped."
184 _fail="${_fail} ${ifn}"
185 continue
186 fi

--- 43 unchanged lines hidden ---