summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh
blob: 7267969cea48c9cdd11750f745ebcba377809a17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/ash
# Copyright (c) 2009 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
#
# XEN specific init hook to create a bridge on the active network interface
#############################################################################

# configure Xen bridge xenbr0 (would it be possible to make it just br0?)

modprobe ${MODPRV} netloop
local ipls
local vifnum="0"
local bridge="xenbr${vifnum}"
local netdev="eth${vifnum}"    # should be ${nwif}
local pdev="p${netdev}"
local vdev="veth${vifnum}"
local vif0="vif0.${vifnum}"
# fixme: that is the mac address of main ethernet device
local mac=${macaddr}

brctl addbr ${bridge}
brctl stp ${bridge} off
brctl setfd ${bridge} 0.000000000001
brctl addif ${bridge} ${vif0}
for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \
            "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \
            "${netdev} addr ${mac} arp on" "${netdev} addr ${mac} arp on" \
            "${bridge} up" "${vif0} up" "${pdev} up" ; do
  ip link set ${ipls}
done
brctl addif ${bridge} ${pdev}

# fixme: sending back the variable to init does not work properly at the
# moment
nwif=${bridge}