]>
git.proxmox.com Git - mirror_ovs.git/blob - xenserver/etc_xensource_scripts_vif
3 # This file is based on /etc/xensource/script/vif from Citrix XenServer 5.0.0.
4 # The original file did not contain a copyright notice or license statement.
6 # Copyright (C) 2009 Nicira Networks, Inc.
8 # CA-23900: Warning: when VIFs are added to windows guests with PV drivers the backend vif device is registered,
9 # unregistered and then registered again. This causes the udev event to fire twice and this script runs twice.
10 # Since the first invocation of the script races with the device unregistration, spurious errors are possible
11 # which will be logged but are safe to ignore since the second script invocation should complete the operation.
12 # Note that each script invocation is run synchronously from udev and so the scripts don't race with each other.
14 # Keep other-config/ keys in sync with device.ml:vif_udev_keys
16 cfg_mod
="/root/vswitch/bin/ovs-cfg-mod"
17 service
="/sbin/service"
19 TYPE
=`echo ${XENBUS_PATH} | cut -f 2 -d '/'`
20 DOMID
=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
21 DEVID
=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
23 XAPI
=/xapi
/${DOMID}/hotplug/${TYPE}/${DEVID}
24 HOTPLUG
=/xapi
/${DOMID}/hotplug/${TYPE}/${DEVID}
25 PRIVATE
=/xapi
/${DOMID}/private/${TYPE}/${DEVID}
32 local arg
=$
(xenstore-read
"${PRIVATE}/other-config/promiscuous")
33 if [ $?
-eq 0 -a -n "${arg}" ] ; then
35 true|on
) echo 1 > /sys
/class
/net
/${vif}/brport
/promisc
;;
36 *) echo 0 > /sys
/class
/net
/${vif}/brport
/promisc
;;
44 local arg
=$
(xenstore-read
"${PRIVATE}/other-config/ethtool-${opt}")
45 if [ $?
-eq 0 -a -n "${arg}" ] ; then
47 true|on
) /sbin
/ethtool
-K "${vif}" "${opt}" on
;;
48 false|off
) /sbin
/ethtool
-K "${vif}" "${opt}" off
;;
49 *) logger
-t scripts-vif
"Unknown ethtool argument ${opt}=${arg} on ${vif}/${VIFUUID}" ;;
56 local mtu
=$
(xenstore-read
"${PRIVATE}/MTU")
57 if [ $?
-eq 0 -a -n "${mtu}" ]; then
58 echo "${mtu}" > /sys
/class
/net
/${vif}/mtu
64 local address
=$
(xenstore-read
"${PRIVATE}/bridge-MAC")
65 if [ $?
-ne 0 -o -z "${address}" ]; then
66 logger
-t scripts-vif
"Failed to read ${PRIVATE}/bridge-MAC from xenstore"
68 local bridge
=$
(xenstore-read
"${PRIVATE}/bridge")
69 if [ $?
-ne 0 -o -z "${bridge}" ]; then
70 logger
-t scripts-vif
"Failed to read ${PRIVATE}/bridge from xenstore"
72 logger
-t scripts-vif
"Adding ${vif} to ${bridge} with address ${address}"
75 if [ -e "/etc/openvswitch/br-$bridge" ]; then
76 .
"/etc/openvswitch/br-$bridge"
77 if [ -n "$VLAN_SLAVE" -a -n "$VLAN_VID" ]; then
79 vid
="--add=vlan.$vif.tag=$VLAN_VID"
83 ${IP} link set "${vif}" down || logger -t scripts-vif "Failed to ip link set ${vif} down
"
84 ${IP} link set "${vif}" arp off || logger -t scripts-vif "Failed to ip link set ${vif} arp off"
85 ${IP} link set "${vif}" multicast off || logger -t scripts-vif "Failed to ip link set ${vif} multicast off
"
86 ${IP} link set "${vif}" address "${address}" || logger -t scripts-vif "Failed to ip link set ${vif} address ${address}"
87 ${IP} addr flush "${vif}" || logger -t scripts-vif "Failed to ip addr flush ${vif}"
89 $cfg_mod -F /etc/ovs-vswitchd.conf \
90 --del-match="bridge.
*.port
=$vif" \
91 --del-match="vlan.
$vif.
[!0-9]*" \
92 --del-match="port.
$vif.
[!0-9]*" \
93 --add="bridge.
$bridge.port
=$vif" \
95 $service vswitch reload
97 ${IP} link set "${vif}" up || logger -t scripts-vif "Failed to ip link set ${vif} up"
100 echo Called as
"$@" "$TYPE" "$DOMID" "$DEVID" | logger
-t scripts-vif
114 xenstore-write
"${HOTPLUG}/vif" "${vif}"
115 xenstore-write
"${HOTPLUG}/hotplug" "online"
117 # xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
118 xenstore-write
"/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
122 xenstore-rm
"${HOTPLUG}/hotplug"
123 vif
=vif
${DOMID}.
${DEVID}
124 logger
-t scripts-vif
"${vif} has been removed"
125 $cfg_mod -vANY:console
:emer
-F /etc
/ovs-vswitchd.conf \
126 --del-match="bridge.*.port=${vif}" \
127 --del-match="vlan.${vif}.[!0-9]*" \
128 --del-match="port.${vif}.[!0-9]*" -c