]> git.proxmox.com Git - mirror_ovs.git/blame - debian/ifupdown.sh
datapath: Cleanup netlink compat code.
[mirror_ovs.git] / debian / ifupdown.sh
CommitLineData
86b87c92
GS
1#! /bin/sh
2
fba6bd1d 3# Copyright (c) 2012, 2013 Nicira, Inc.
86b87c92
GS
4#
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:
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17# Have a look at /usr/share/doc/openvswitch-switch/README.Debian
18# for more information about configuring the /etc/network/interfaces.
19
20if [ -z "${IF_OVS_TYPE}" ]; then
21 exit 0
22fi
23
24ovs_vsctl() {
0daa9cf2 25 ovs-vsctl --timeout=5 "$@"
86b87c92
GS
26}
27
28if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
29 exit 0
30fi
31
32if [ "${MODE}" = "start" ]; then
33 eval OVS_EXTRA=\"${IF_OVS_EXTRA}\"
34
35 case "${IF_OVS_TYPE}" in
36 OVSBridge)
37 ovs_vsctl -- --may-exist add-br "${IFACE}" ${IF_OVS_OPTIONS}\
38 ${OVS_EXTRA+-- $OVS_EXTRA}
39
40 if [ ! -z "${IF_OVS_PORTS}" ]; then
41 ifup --allow="${IFACE}" ${IF_OVS_PORTS}
42 fi
43 ;;
44 OVSPort)
45 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
46 "${IFACE}" ${IF_OVS_OPTIONS} \
47 ${OVS_EXTRA+-- $OVS_EXTRA}
48
49 ifconfig "${IFACE}" up
50 ;;
51 OVSIntPort)
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}
55
56 ifconfig "${IFACE}" up
57 ;;
58 OVSBond)
59 ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
60 "${IFACE}" ${IF_OVS_BONDS} ${IF_OVS_OPTIONS} \
61 ${OVS_EXTRA+-- $OVS_EXTRA}
62
63 ifconfig "${IFACE}" up
41fc9c18
GS
64 for slave in ${IF_OVS_BONDS}
65 do
66 ifconfig "${slave}" up
67 done
86b87c92
GS
68 ;;
69 *)
70 exit 0
71 ;;
72 esac
73elif [ "${MODE}" = "stop" ]; then
74 case "${IF_OVS_TYPE}" in
75 OVSBridge)
76 if [ ! -z "${IF_OVS_PORTS}" ]; then
77 ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
78 fi
79
80 ovs_vsctl -- --if-exists del-br "${IFACE}"
81 ;;
82 OVSPort|OVSIntPort|OVSBond)
83 ovs_vsctl -- --if-exists del-port "${IF_OVS_BRIDGE}" "${IFACE}"
84 ;;
85 *)
86 exit 0
87 ;;
88 esac
89fi
90
91exit 0