| #!/bin/bash |
| # Copyright (C) 2008-2011, Parallels, Inc. All rights reserved. |
| # |
| # Update ARP table for all containers on interface up |
| |
| [ ! -f /proc/vz/veip ] && exit 0 |
| |
| usage() |
| { |
| echo "Usage: $(basename $0) DEVICE" 1>&2 |
| exit 1 |
| } |
| |
| # Supplied interface name |
| DEV=$1 |
| [ -z "${DEV}" ] && usage |
| |
| test -f @PKGLIBDIR@/scripts/vps-functions || exit 1 |
| test -f @PKGCONFDIR@/vz.conf || exit 1 |
| . @PKGLIBDIR@/scripts/vps-functions |
| . @PKGCONFDIR@/vz.conf |
| |
| update_arp() |
| { |
| local veip |
| for veip in $(awk '!/^Version/ { print $1 }' /proc/vz/veip); do |
| [ "$NEIGHBOUR_DEVS" = 'detect' ] && vzdelrouting "${veip}" |
| vzarp add ${veip} |
| [ "$NEIGHBOUR_DEVS" = 'detect' ] && vzaddrouting "${veip}" |
| done |
| } |
| |
| # Get possible interface names |
| vzgetnetdev |
| [ -z "${NETDEVICES}" ] && exit 0 |
| |
| # Check if a device name given is in the list returned by vzgetnetdev |
| # Indeed we do not want to add arp entries for e.g. 'lo' |
| echo "${NETDEVICES}" | grep -qw "${DEV}" || exit 0 |
| |
| NETDEVICES="${DEV}" |
| update_arp |
| exit 0 |