3 # Copyright (c) 2012 Nicira, Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Have a look at /usr/share/doc/openvswitch-switch/README.Debian
18 # for more information about configuring the /etc/network/interfaces.
20 if [ -z "${IF_OVS_TYPE}" ]; then
25 ovs-vsctl --timeout=5 "$@"
28 if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
32 if [ "${MODE}" = "start" ]; then
33 eval OVS_EXTRA=\"${IF_OVS_EXTRA}\"
35 case "${IF_OVS_TYPE}" in
37 ovs_vsctl -- --may-exist add-br "${IFACE}" ${IF_OVS_OPTIONS}\
38 ${OVS_EXTRA+-- $OVS_EXTRA}
40 if [ ! -z "${IF_OVS_PORTS}" ]; then
41 ifup --allow="${IFACE}" ${IF_OVS_PORTS}
45 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
46 "${IFACE}" ${IF_OVS_OPTIONS} \
47 ${OVS_EXTRA+-- $OVS_EXTRA}
49 ifconfig "${IFACE}" up
52 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
53 "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}"\
54 type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
56 ifconfig "${IFACE}" up
59 ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
60 "${IFACE}" ${IF_OVS_BONDS} ${IF_OVS_OPTIONS} \
61 ${OVS_EXTRA+-- $OVS_EXTRA}
63 ifconfig "${IFACE}" up
64 for slave in ${IF_OVS_BONDS}
66 ifconfig "${slave}" up
73 elif [ "${MODE}" = "stop" ]; then
74 case "${IF_OVS_TYPE}" in
76 if [ ! -z "${IF_OVS_PORTS}" ]; then
77 ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
80 ovs_vsctl -- --if-exists del-br "${IFACE}"
82 OVSPort|OVSIntPort|OVSBond)
83 ovs_vsctl -- --if-exists del-port "${IF_OVS_BRIDGE}" "${IFACE}"