Statistics
| Branch: | Tag: | Revision:

root / fix-net @ cae36f02

History | View | Annotate | Download (1.7 kB)

1
#!/bin/bash
2

    
3
MAC2EUI64=/usr/bin/mac2eui64
4

    
5
source /etc/default/snf-network
6

    
7
host=$(hostname)
8
domain=$(hostname -d)
9

    
10
FIRST=0
11
LAST=$((GANETI_INSTANCE_NIC_COUNT - 1))
12
for idx in $(seq $FIRST $LAST); do
13
  ip=GANETI_INSTANCE_NIC${idx}_IP
14
  mac=GANETI_INSTANCE_NIC${idx}_MAC
15
  mode=GANETI_INSTANCE_NIC${idx}_MODE
16
  link=GANETI_INSTANCE_NIC${idx}_LINK
17
  network=GANETI_INSTANCE_NIC${idx}_NETWORK_SUBNET
18
  subnet6=GANETI_INSTANCE_NIC${idx}_NETWORK_SUBNET6
19
  tags=GANETI_INSTANCE_NIC${idx}_NETWORK_TAGS
20
  eval IP=\$$ip
21
  eval MAC=\$$mac
22
  eval MODE=\$$mode
23
  eval LINK=\$$link
24
  eval NETWORK=\$$network
25
  eval SUBNET6=\$$subnet6
26
  eval TAGS=\$$tags
27

    
28
  for tag in $TAGS; do
29
    case $tag in
30
    $IP_LESS_ROUTED_TAG)
31
      uplink=$(ip route list table $LINK | grep "default via" | awk '{print $5}')
32
      uplink6=$(ip -6 route list table $LINK | grep "default via" | awk '{print $5}')
33
      eui64=$($MAC2EUI64 $MAC $SUBNET6 2>/dev/null)
34
      if [ "$GANETI_INSTANCE_OLD_PRIMARY" == "$host.$domain" ]; then
35
        # This runs on the source node
36
        hooks-log $0 "ip -6 neigh del proxy $eui64 dev $uplink6"
37
        ip -6 neigh del proxy $eui64 dev $uplink6 >/dev/null 2>&1
38
      elif [ "$GANETI_INSTANCE_NEW_PRIMARY" == "$host.$domain" ]; then
39
        # This runs on the target node
40
        # Send GARP from host to upstream router to speed up mac change for the VMs IP
41
        hooks-log $0 "arping  -c3 -I $uplink -U $IP"
42
        echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
43
        arping  -c3 -I $uplink -U $IP
44
        echo 0 > /proc/sys/net/ipv4/ip_nonlocal_bind
45
        # Send Unsolicited Neighbor Advertisement to speed up nd change for the VMs IP
46
        hooks-log $0 "ndsend $eui64 $uplink6"
47
        ndsend $eui64 $uplink6
48
      fi
49
    ;;
50
    esac
51
  done
52
done
53

    
54
exit 0