1 /******************************************************************************
2 *******************************************************************************
4 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5 ** Copyright (C) 2004 Red Hat, Inc. All rights reserved.
7 ** This copyrighted material is made available to anyone wishing to use,
8 ** modify, copy, or redistribute it subject to the terms and conditions
9 ** of the GNU General Public License v.2.
11 *******************************************************************************
12 ******************************************************************************/
14 /* CMAN socket interface header,
15 may be include by user or kernel code */
17 #ifndef __CNXMAN_SOCKET_H
18 #define __CNXMAN_SOCKET_H
20 /* A currently unused number. TIPC also uses this number and you're unlikely
24 #define PF_CLUSTER AF_CLUSTER
26 /* Protocol(socket) types */
27 #define CLPROTO_MASTER 2
28 #define CLPROTO_CLIENT 3
30 /* ioctls -- should register these properly */
31 #define SIOCCLUSTER_NOTIFY _IOW('x', 0x01, int)
32 #define SIOCCLUSTER_REMOVENOTIFY _IO( 'x', 0x02)
33 #define SIOCCLUSTER_GETMEMBERS _IOR('x', 0x03, struct cl_cluster_nodelist)
34 #define SIOCCLUSTER_SETEXPECTED_VOTES _IOW('x', 0x04, int)
35 #define SIOCCLUSTER_ISQUORATE _IO( 'x', 0x05)
36 #define SIOCCLUSTER_ISLISTENING _IOW('x', 0x06, struct cl_listen_request)
37 #define SIOCCLUSTER_GETALLMEMBERS _IOR('x', 0x07, struct cl_cluster_nodelist)
38 #define SIOCCLUSTER_SET_VOTES _IOW('x', 0x08, int)
39 #define SIOCCLUSTER_GET_VERSION _IOR('x', 0x09, struct cl_version)
40 #define SIOCCLUSTER_SET_VERSION _IOW('x', 0x0a, struct cl_version)
41 #define SIOCCLUSTER_ISACTIVE _IO( 'x', 0x0b)
42 #define SIOCCLUSTER_KILLNODE _IOW('x', 0x0c, int)
43 #define SIOCCLUSTER_GET_JOINCOUNT _IO( 'x', 0x0d)
44 #define SIOCCLUSTER_SERVICE_REGISTER _IOW('x', 0x0e, char)
45 #define SIOCCLUSTER_SERVICE_UNREGISTER _IO('x', 0x0f)
46 #define SIOCCLUSTER_SERVICE_JOIN _IO( 'x', 0x10)
47 #define SIOCCLUSTER_SERVICE_LEAVE _IO( 'x', 0x20)
48 #define SIOCCLUSTER_SERVICE_SETSIGNAL _IOW('x', 0x30, int)
49 #define SIOCCLUSTER_SERVICE_STARTDONE _IOW('x', 0x40, unsigned int)
50 #define SIOCCLUSTER_SERVICE_GETEVENT _IOR('x', 0x50, struct cl_service_event)
51 #define SIOCCLUSTER_SERVICE_GETMEMBERS _IOR('x', 0x60, struct cl_cluster_nodelist)
52 #define SIOCCLUSTER_SERVICE_GLOBALID _IOR('x', 0x70, uint32_t)
53 #define SIOCCLUSTER_SERVICE_SETLEVEL _IOR('x', 0x80, int)
54 #define SIOCCLUSTER_GETNODE _IOWR('x', 0x90, struct cl_cluster_node)
55 #define SIOCCLUSTER_GETCLUSTER _IOWR('x', 0x91, struct cl_cluster_info)
56 #define SIOCCLUSTER_BARRIER _IOW('x', 0x0a0, struct cl_barrier_info)
58 /* These were setsockopts */
59 #define SIOCCLUSTER_PASS_SOCKET _IOW('x', 0x0b0, struct cl_passed_sock)
60 #define SIOCCLUSTER_SET_NODENAME _IOW('x', 0x0b1, char *)
61 #define SIOCCLUSTER_SET_NODEID _IOW('x', 0x0b2, int)
62 #define SIOCCLUSTER_JOIN_CLUSTER _IOW('x', 0x0b3, struct cl_join_cluster_info)
63 #define SIOCCLUSTER_LEAVE_CLUSTER _IOW('x', 0x0b4, int)
66 /* Maximum size of a cluster message */
67 #define MAX_CLUSTER_MESSAGE 1500
68 #define MAX_CLUSTER_MEMBER_NAME_LEN 255
69 #define MAX_BARRIER_NAME_LEN 33
70 #define MAX_SA_ADDR_LEN 12
71 #define MAX_CLUSTER_NAME_LEN 16
73 /* Well-known cluster port numbers */
74 #define CLUSTER_PORT_MEMBERSHIP 1 /* Mustn't block during cluster
76 #define CLUSTER_PORT_SERVICES 2
77 #define CLUSTER_PORT_SYSMAN 10 /* Remote execution daemon */
78 #define CLUSTER_PORT_CLVMD 11 /* Cluster LVM daemon */
79 #define CLUSTER_PORT_SLM 12 /* LVM SLM (simple lock manager) */
81 /* Port numbers above this will be blocked when the cluster is inquorate or in
83 #define HIGH_PROTECTED_PORT 9
85 /* Reasons for leaving the cluster */
86 #define CLUSTER_LEAVEFLAG_DOWN 0 /* Normal shutdown */
87 #define CLUSTER_LEAVEFLAG_KILLED 1
88 #define CLUSTER_LEAVEFLAG_PANIC 2
89 #define CLUSTER_LEAVEFLAG_REMOVED 3 /* This one can reduce quorum */
90 #define CLUSTER_LEAVEFLAG_REJECTED 4 /* Not allowed into the cluster in the
92 #define CLUSTER_LEAVEFLAG_INCONSISTENT 5 /* Our view of the cluster is
94 #define CLUSTER_LEAVEFLAG_DEAD 6 /* Discovered to be dead */
95 #define CLUSTER_LEAVEFLAG_NORESPONSE 7 /* Didn't ACK message */
96 #define CLUSTER_LEAVEFLAG_FORCE 0x10 /* Forced by command-line */
98 /* OOB messages sent to a local socket */
99 #define CLUSTER_OOB_MSG_PORTCLOSED 1
100 #define CLUSTER_OOB_MSG_STATECHANGE 2
101 #define CLUSTER_OOB_MSG_SERVICEEVENT 3
103 /* Sendmsg flags, these are above the normal sendmsg flags so they don't
105 #define MSG_NOACK 0x010000 /* Don't need an ACK for this message */
106 #define MSG_QUEUE 0x020000 /* Queue the message for sending later */
107 #define MSG_MULTICAST 0x080000 /* Message was sent to all nodes in the cluster
109 #define MSG_ALLINT 0x100000 /* Send out of all interfaces */
110 #define MSG_REPLYEXP 0x200000 /* Reply is expected */
111 #define MSG_BCASTSELF 0x400000 /* Broadcast message also gets send to us */
113 typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
114 NODESTATE_DEAD } nodestate_t;
118 unsigned short scl_family;
119 unsigned char scl_flags;
120 unsigned char scl_port;
125 * This is how we pass the multicast & receive sockets into kernel space.
127 struct cl_passed_sock {
128 int fd; /* FD of master socket to do multicast on */
129 int number; /* Socket number, to match up recvonly & bcast
131 int multicast; /* Is it multicast or receive ? */
134 /* Cluster configuration info passed when we join the cluster */
135 struct cl_join_cluster_info {
137 unsigned int expected_votes;
138 unsigned int two_node;
139 unsigned int config_version;
141 char cluster_name[17];
145 /* This is the structure, per node, returned from the membership ioctl */
146 struct cl_cluster_node {
148 unsigned int node_id;
150 unsigned int leave_reason;
151 unsigned int incarnation;
153 char name[MAX_CLUSTER_MEMBER_NAME_LEN];
157 /* The struct passed to the membership ioctls */
158 struct cl_cluster_nodelist {
159 uint32_t max_members;
160 struct cl_cluster_node *nodes;
163 /* Structure passed to SIOCCLUSTER_ISLISTENING */
164 struct cl_listen_request {
169 /* A Cluster PORTCLOSED message - received by a local user as an OOB message */
170 struct cl_portclosed_oob {
171 unsigned char cmd; /* CLUSTER_OOB_MSG_PORTCLOSED */
175 /* Get all version numbers or set the config version */
183 /* structure passed to barrier ioctls */
184 struct cl_barrier_info {
186 char name[MAX_BARRIER_NAME_LEN];
191 struct cl_cluster_info {
192 char name[MAX_CLUSTER_NAME_LEN+1];
196 typedef enum { SERVICE_EVENT_STOP, SERVICE_EVENT_START, SERVICE_EVENT_FINISH,
197 SERVICE_EVENT_LEAVEDONE } service_event_t;
199 typedef enum { SERVICE_START_FAILED, SERVICE_START_JOIN, SERVICE_START_LEAVE }
202 struct cl_service_event {
203 service_event_t type;
204 service_start_t start_type;
205 unsigned int event_id;
206 unsigned int last_stop;
207 unsigned int last_start;
208 unsigned int last_finish;
209 unsigned int node_count;
213 /* Commands to the barrier ioctl */
214 #define BARRIER_IOCTL_REGISTER 1
215 #define BARRIER_IOCTL_CHANGE 2
216 #define BARRIER_IOCTL_DELETE 3
217 #define BARRIER_IOCTL_WAIT 4
219 /* Attributes of a barrier - bitmask */
220 #define BARRIER_ATTR_AUTODELETE 1
221 #define BARRIER_ATTR_MULTISTEP 2
222 #define BARRIER_ATTR_MANUAL 4
223 #define BARRIER_ATTR_ENABLED 8
224 #define BARRIER_ATTR_CALLBACK 16
226 /* Attribute setting commands */
227 #define BARRIER_SETATTR_AUTODELETE 1
228 #define BARRIER_SETATTR_MULTISTEP 2
229 #define BARRIER_SETATTR_ENABLED 3
230 #define BARRIER_SETATTR_NODES 4
231 #define BARRIER_SETATTR_CALLBACK 5
232 #define BARRIER_SETATTR_TIMEOUT 6