Revision 26916aad

b/.gitignore
74 74
/man/*.in
75 75
/man/footer.man
76 76

  
77
# tools
78
/tools/kvm-ifup
79

  
77 80
# scripts
78 81
/scripts/gnt-backup
79 82
/scripts/gnt-cluster
b/Makefile.am
103 103
	doc/examples/hooks/ipsec \
104 104
	$(man_MANS) \
105 105
	$(manhtml) \
106
	tools/kvm-ifup \
106 107
	stamp-srclinks \
107 108
	$(nodist_pkgpython_PYTHON)
108 109

  
......
364 365
pkglib_SCRIPTS = \
365 366
	daemons/daemon-util \
366 367
	daemons/ensure-dirs \
368
	tools/kvm-ifup \
367 369
	$(pkglib_python_scripts)
368 370

  
369 371
EXTRA_DIST = \
......
383 385
	daemons/ganeti-cleaner.in \
384 386
	$(pkglib_python_scripts) \
385 387
	devel/upload.in \
388
	tools/kvm-ifup.in \
386 389
	$(docdot) \
387 390
	$(docpng) \
388 391
	$(docrst) \
......
571 574

  
572 575
test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
573 576

  
577
tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
578
	sed -f $(REPLACE_VARS_SED) < $< > $@
579
	chmod +x $@
580

  
574 581
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
575 582
	sed -f $(REPLACE_VARS_SED) < $< > $@
576 583
	chmod u+x $@
b/lib/constants.py
141 141
QUEUE_DIR = DATA_DIR + "/queue"
142 142
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
143 143
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
144
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
144 145
ETC_HOSTS = "/etc/hosts"
145 146
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
146 147
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
b/tools/kvm-ifup.in
1
#!/bin/sh
2

  
3
# Copyright (C) 2011 Google Inc.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
if [ -z "$INTERFACE" ]; then
21
	echo "No network interface specified"
22
	exit 1
23
fi
24

  
25
if [ -z "$MODE" ]; then
26
	echo "MODE not specified"
27
	exit 1
28
fi
29

  
30
# Execute the user-supplied network script, if applicable
31
if [ -x "@SYSCONFDIR@/ganeti/kvm-vif-bridge" ]; then
32
	exec @SYSCONFDIR@/ganeti/kvm-vif-bridge
33
fi
34

  
35
ip link set $INTERFACE up
36

  
37
if [ "$MODE" == "bridged" ]; then
38
	# Connect the interface to the bridge
39
	brctl addif $BRIDGE $INTERFACE
40
else
41
	if [ -z "$IP" ]; then
42
		echo "Routed NIC but no IP address specified"
43
		exit 1
44
	fi
45

  
46
	# Route traffic targeted at the IP to the interface
47
	if [ -n "$LINK" ]; then
48
		while ip rule del dev $INTERFACE; do :; done
49
		ip rule add dev $INTERFACE table $LINK
50
		ip route replace $IP table $LINK proto static dev $INTERFACE
51

  
52
	else
53
		ip route replace $IP proto static dev $INTERFACE
54
	fi
55

  
56
	if [ -d "/proc/sys/net/ipv4/conf/$INTERFACE" ]; then
57
		echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/proxy_arp
58
		echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
59
	fi
60

  
61
	if [ -d "/proc/sys/net/ipv6/conf/$INTERFACE" ]; then
62
		echo 1 > /proc/sys/net/ipv6/conf/$INTERFACE/proxy_ndp
63
		echo 1 > /proc/sys/net/ipv6/conf/$INTERFACE/forwarding
64
	fi
65
fi

Also available in: Unified diff