1#!/bin/sh -e 2# 3# FreeBSD hotplug script for attaching xnb* interfaces to bridges 4# 5# Parameters: 6# $1: xenstore backend path of the vif 7# $2: action, either "add" or "remove" 8# 9# Environment variables: 10# $iface_dev: name of the backend device (xnb<domid>.<handle>) 11# 12 13DIR=$(dirname "$0") 14. "${DIR}/hotplugpath.sh" 15 16PATH=${bindir}:${sbindir}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin 17export PATH 18 19path=$1 20action=$2 21 22case $action in 23add) 24 bridge=$(xenstore-read "$path/bridge") 25 mtu=$(ifconfig $bridge | sed -n 's/.*mtu \([0-9]*\)$/\1/p') 26 ifconfig $iface_dev mtu $mtu 27 ifconfig $bridge addm $iface_dev 28 ifconfig $iface_dev up 29 exit 0 30 ;; 31remove) 32 if [ "$emulated" -eq 1 ]; then 33 bridge=$(xenstore-read "$path/bridge") 34 ifconfig $iface_dev down 35 ifconfig $bridge deletem $iface_dev 36 ifconfig $iface_dev destroy 37 fi 38 exit 0 39 ;; 40*) 41 exit 0 42 ;; 43esac 44