Statistics
| Branch: | Tag: | Revision:

root / vif-custom @ bd59aebc

History | View | Annotate | Download (1.5 kB)

1
#!/bin/bash
2

    
3

    
4
dir=$(dirname "$0")
5
. "$dir"/vif-common.sh
6

    
7
# taken from older vif-common.sh
8
dev=$vif
9
dev_=${dev#vif}
10
domid=${dev_%.*}
11
devid=${dev_#*.}
12
domname=$(xm domname $domid)
13

    
14
source /etc/default/snf-network
15
source /usr/lib/snf-network/common.sh
16
source $GANETI_NIC_DIR/$domname/$devid
17

    
18
INTERFACE=$dev
19
INSTANCE=$domname
20

    
21
GANETI_INSTANCE_NAME=$INSTANCE
22
get_info
23

    
24
try clear_routed_setup_ipv4
25
try clear_routed_setup_ipv6
26
try clear_routed_setup_firewall
27
try clear_ebtables
28
try clear_nfdhcpd
29

    
30
if [ "$MODE" = "routed" ]; then
31
  TABLE=$LINK
32
  ip link set $INTERFACE up
33
  success
34
  INDEV=$INTERFACE
35
  DROPDHCPREQCMD="iptables -A FORWARD -i $INTERFACE -p udp --dport 67 -j DROP"
36
elif [ "$MODE" = "bridged" ]; then
37
  ip link set $INTERFACE up
38
  BRIDGE=$(xenstore_read_default "$XENBUS_PATH/bridge" "$LINK")
39
  brctl addif $BRIDGE $INTERFACE
40
  success
41
  INDEV=$BRIDGE
42
  try init_ebtables
43
  # nfdhcpd creates responses with src mac the mac of indec
44
  INDEV_MAC=$(cat /sys/class/net/$INDEV/address)
45
  DROPDHCPREQCMD="runlocked $RUNLOCKED_OPTS ebtables -A $FROM -p ipv4 --ip-protocol udp --ip-destination-port 67 -j DROP"
46
fi
47

    
48
for tag in $NETWORK_TAGS; do
49
  case $tag in
50
  $IP_LESS_ROUTED_TAG)
51
    try routed_setup_ipv4
52
    try routed_setup_ipv6
53
    try routed_setup_firewall
54
    try send_garp
55
  ;;
56
  $NFDHCPD_TAG)
57
    # Drop unicast BOOTP/DHCP packets
58
    $DROPDHCPREQCMD
59
    try setup_nfdhcpd
60
  ;;
61
  $MAC_FILTERED_TAG)
62
    try setup_ebtables
63
  ;;
64
  $MASQ_TAG)
65
    try setup_masq
66
  ;;
67
  esac
68
done