3 # OCF RA for tunctl(1) TUN/TAP device initialization
5 # Copyright (c) 2008,2009 Barton IT-Consulting
6 # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like. Any license provided herein, whether implied or
20 # otherwise, applies only to this software file. Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
30 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
32 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
38 <resource-agent name="TunCtl">
39 <version>1.1</version>
42 OCF RA for tunctl(1) TUN/TAP device initialization.
44 <shortdesc lang="en">TUN/TAP device initialization</shortdesc>
47 <parameter name="if_name" unique="1">
48 <shortdesc lang="en">Name of TUN/TAP interface</shortdesc>
49 <content type="string" default="" />
51 <parameter name="if_owner" unique="1">
52 <shortdesc lang="en">TUN/TAP interface owner</shortdesc>
53 <content type="string" default="" />
55 <parameter name="host_ip" unique="1">
56 <shortdesc lang="en">Host-side IP address</shortdesc>
57 <content type="string" default="" />
59 <parameter name="host_netmask" unique="1">
60 <shortdesc lang="en">Host-side netmask</shortdesc>
61 <content type="string" default="" />
63 <parameter name="client_ip" unique="1">
64 <shortdesc lang="en">Client-side IP address</shortdesc>
65 <content type="string" default="" />
67 <parameter name="if_proxyarp" unique="1">
68 <shortdesc lang="en">Interface for Proxy-ARP</shortdesc>
69 <content type="string" default="" />
74 <action name="start" timeout="10" />
75 <action name="stop" timeout="10" />
76 <action name="monitor" timeout="10" interval="15" depth="0" start-delay="5" />
77 <action name="meta-data" timeout="5" />
78 <action name="verify-all" timeout="30" />
84 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87 echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
91 tunctl -u "${OCF_RESKEY_if_owner:-root}" -t "$OCF_RESKEY_if_name"
93 return $OCF_ERR_GENERIC
95 ifconfig "$OCF_RESKEY_if_name" "$OCF_RESKEY_host_ip" \
96 netmask "${OCF_RESKEY_host_netmask:-255.255.255.0}" up
98 return $OCF_ERR_GENERIC
100 echo 1 >/proc/sys/net/ipv4/ip_forward
101 route add -host "$OCF_RESKEY_client_ip" dev "$OCF_RESKEY_if_name"
102 if [ $? -ne 0 ]; then
103 return $OCF_ERR_GENERIC
105 if [ -n "$OCF_RESKEY_if_proxyarp" ]; then
107 echo 1 >/proc/sys/net/ipv4/conf/"$OCF_RESKEY_if_name"/proxy_arp
108 if [ $? -ne 0 ]; then
109 return $OCF_ERR_GENERIC
111 arp -Ds "$OCF_RESKEY_client_ip" "$OCF_RESKEY_if_proxyarp" pub
112 if [ $? -ne 0 ]; then
113 return $OCF_ERR_GENERIC
120 if [ -n "$OCF_RESKEY_if_proxyarp" ]; then
122 arp -d "$OCF_RESKEY_client_ip" -i "$OCF_RESKEY_if_proxyarp" pub
124 ifconfig "$OCF_RESKEY_if_name" down >/dev/null 2>&1
125 tunctl -d "$OCF_RESKEY_if_name"
126 if [ $? -eq 0 ]; then
129 return $OCF_ERR_GENERIC
133 ip link show "$OCF_RESKEY_if_name" | grep "UP" >/dev/null 2>&1
134 if [ $? -eq 0 ]; then
137 return $OCF_NOT_RUNNING
141 if [ -z "$OCF_RESKEY_if_name" ]; then
144 if [ -z "$OCF_RESKEY_host_ip" ]; then
147 if [ -z "$OCF_RESKEY_client_ip" ]; then
153 case $__OCF_ACTION in
176 exit $OCF_ERR_UNIMPLEMENTED
181 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"