3 # Copyright (c) 2012, 2013 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 /etc/init.d/openvswitch-switch status > /dev/null 2>&1; then :; else
33 /etc/init.d/openvswitch-switch start
36 if [ "${MODE}" = "start" ]; then
37 eval OVS_EXTRA=\"${IF_OVS_EXTRA}\"
39 case "${IF_OVS_TYPE}" in
41 ovs_vsctl -- --may-exist add-br "${IFACE}" ${IF_OVS_OPTIONS}\
42 ${OVS_EXTRA+-- $OVS_EXTRA}
44 if [ ! -z "${IF_OVS_PORTS}" ]; then
45 ifup --allow="${IFACE}" ${IF_OVS_PORTS}
49 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
50 "${IFACE}" ${IF_OVS_OPTIONS} \
51 ${OVS_EXTRA+-- $OVS_EXTRA}
53 ifconfig "${IFACE}" up
56 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
57 "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}"\
58 type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
60 ifconfig "${IFACE}" up
63 ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
64 "${IFACE}" ${IF_OVS_BONDS} ${IF_OVS_OPTIONS} \
65 ${OVS_EXTRA+-- $OVS_EXTRA}
67 ifconfig "${IFACE}" up
68 for slave in ${IF_OVS_BONDS}
70 ifconfig "${slave}" up
74 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
75 "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}" \
76 type=patch options:peer="${IF_OVS_PATCH_PEER}" \
77 ${OVS_EXTRA+-- $OVS_EXTRA}
80 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
81 "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}" \
82 type=${IF_OVS_TUNNEL_TYPE} ${IF_OVS_TUNNEL_OPTIONS} \
83 ${OVS_EXTRA+-- $OVS_EXTRA}
89 elif [ "${MODE}" = "stop" ]; then
90 case "${IF_OVS_TYPE}" in
92 if [ ! -z "${IF_OVS_PORTS}" ]; then
93 ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
96 ovs_vsctl -- --if-exists del-br "${IFACE}"
98 OVSPort|OVSIntPort|OVSBond|OVSPatchPort|OVSTunnel)
99 ovs_vsctl -- --if-exists del-port "${IF_OVS_BRIDGE}" "${IFACE}"