1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM *
4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM *
8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM * and limitations under the License.
12*7836SJohn.Forte@Sun.COM *
13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM *
19*7836SJohn.Forte@Sun.COM * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23*7836SJohn.Forte@Sun.COM * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM */
25*7836SJohn.Forte@Sun.COM
26*7836SJohn.Forte@Sun.COM
27*7836SJohn.Forte@Sun.COM #include <sys/types.h>
28*7836SJohn.Forte@Sun.COM #include <stdio.h>
29*7836SJohn.Forte@Sun.COM #include <errno.h>
30*7836SJohn.Forte@Sun.COM #include <strings.h>
31*7836SJohn.Forte@Sun.COM #include <stdlib.h>
32*7836SJohn.Forte@Sun.COM #include <unistd.h>
33*7836SJohn.Forte@Sun.COM #include <netdb.h>
34*7836SJohn.Forte@Sun.COM #include <sys/stream.h>
35*7836SJohn.Forte@Sun.COM #include <sys/socket.h>
36*7836SJohn.Forte@Sun.COM #include <netinet/in.h>
37*7836SJohn.Forte@Sun.COM #include <arpa/inet.h>
38*7836SJohn.Forte@Sun.COM #include <ctype.h>
39*7836SJohn.Forte@Sun.COM #include <thread.h>
40*7836SJohn.Forte@Sun.COM #include <pthread.h>
41*7836SJohn.Forte@Sun.COM
42*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s.h>
43*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s_u.h>
44*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s_impl.h>
45*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_errors.h>
46*7836SJohn.Forte@Sun.COM
47*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_io.h>
48*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_ioctl.h>
49*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_prot.h>
50*7836SJohn.Forte@Sun.COM #include <sys/nsctl/librdc.h>
51*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdcrules.h>
52*7836SJohn.Forte@Sun.COM #include <sys/nsctl/rdcerr.h>
53*7836SJohn.Forte@Sun.COM #include <sys/nsctl/cfg.h>
54*7836SJohn.Forte@Sun.COM
55*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_dtrinkets.h>
56*7836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_etrinkets.h>
57*7836SJohn.Forte@Sun.COM
58*7836SJohn.Forte@Sun.COM #include <sys/socket.h>
59*7836SJohn.Forte@Sun.COM #include <netinet/in.h>
60*7836SJohn.Forte@Sun.COM #include <arpa/inet.h>
61*7836SJohn.Forte@Sun.COM #include <netinet/tcp.h>
62*7836SJohn.Forte@Sun.COM #include <rpc/rpc_com.h>
63*7836SJohn.Forte@Sun.COM #include <rpc/rpc.h>
64*7836SJohn.Forte@Sun.COM
65*7836SJohn.Forte@Sun.COM struct netbuf svaddr, *svp;
66*7836SJohn.Forte@Sun.COM struct netconfig nconf, *conf;
67*7836SJohn.Forte@Sun.COM struct knetconfig knconf;
68*7836SJohn.Forte@Sun.COM
69*7836SJohn.Forte@Sun.COM /*
70*7836SJohn.Forte@Sun.COM * libdscfg type stuff here
71*7836SJohn.Forte@Sun.COM */
72*7836SJohn.Forte@Sun.COM extern int sv_enable(CFGFILE *cfg, rdcconfig_t *rdc);
73*7836SJohn.Forte@Sun.COM extern int add_to_rdc_cfg(rdcconfig_t *rdcs);
74*7836SJohn.Forte@Sun.COM extern int remove_from_rdc_cfg(rdcconfig_t *rdcs);
75*7836SJohn.Forte@Sun.COM extern int replace_cfgfield(rdcconfig_t *rdcs, char *field, char *value);
76*7836SJohn.Forte@Sun.COM extern int reverse_in_cfg(rdcconfig_t *rdcs);
77*7836SJohn.Forte@Sun.COM
78*7836SJohn.Forte@Sun.COM rdcconfig_t *
rdc_dup_config(rdcconfig_t * orig)79*7836SJohn.Forte@Sun.COM rdc_dup_config(rdcconfig_t *orig)
80*7836SJohn.Forte@Sun.COM {
81*7836SJohn.Forte@Sun.COM rdcconfig_t *rc;
82*7836SJohn.Forte@Sun.COM
83*7836SJohn.Forte@Sun.COM rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
84*7836SJohn.Forte@Sun.COM if (!rc) {
85*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
86*7836SJohn.Forte@Sun.COM return (NULL);
87*7836SJohn.Forte@Sun.COM }
88*7836SJohn.Forte@Sun.COM
89*7836SJohn.Forte@Sun.COM *rc = *orig;
90*7836SJohn.Forte@Sun.COM rc->next = NULL; /* don't want to hook into wrong chaing */
91*7836SJohn.Forte@Sun.COM return (rc);
92*7836SJohn.Forte@Sun.COM }
93*7836SJohn.Forte@Sun.COM
94*7836SJohn.Forte@Sun.COM /*
95*7836SJohn.Forte@Sun.COM * takes in a chain of rdcconfig_t's and a chain
96*7836SJohn.Forte@Sun.COM * of rdc_rc_t's, checks for success in the rdc_rc_t,
97*7836SJohn.Forte@Sun.COM * then adds the corresponding rdcconfig_t to the return
98*7836SJohn.Forte@Sun.COM * chain.
99*7836SJohn.Forte@Sun.COM */
100*7836SJohn.Forte@Sun.COM rdcconfig_t *
chain_successful(rdcconfig_t * rdcs,rdc_rc_t * rcs)101*7836SJohn.Forte@Sun.COM chain_successful(rdcconfig_t *rdcs, rdc_rc_t *rcs)
102*7836SJohn.Forte@Sun.COM {
103*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp;
104*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp;
105*7836SJohn.Forte@Sun.COM rdcconfig_t *ret = NULL;
106*7836SJohn.Forte@Sun.COM rdcconfig_t *retp = NULL;
107*7836SJohn.Forte@Sun.COM
108*7836SJohn.Forte@Sun.COM rcp = rcs;
109*7836SJohn.Forte@Sun.COM rdcp = rdcs;
110*7836SJohn.Forte@Sun.COM
111*7836SJohn.Forte@Sun.COM while (rcp) {
112*7836SJohn.Forte@Sun.COM if (rcp->rc == 0) {
113*7836SJohn.Forte@Sun.COM if ((ret == NULL) && (rdcp->persist)) {
114*7836SJohn.Forte@Sun.COM retp = ret = rdc_dup_config(rdcp);
115*7836SJohn.Forte@Sun.COM
116*7836SJohn.Forte@Sun.COM } else if ((ret) && (rdcp->persist)) {
117*7836SJohn.Forte@Sun.COM retp->next = rdc_dup_config(rdcp);
118*7836SJohn.Forte@Sun.COM retp = retp->next;
119*7836SJohn.Forte@Sun.COM }
120*7836SJohn.Forte@Sun.COM }
121*7836SJohn.Forte@Sun.COM rcp = rcp->next;
122*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
123*7836SJohn.Forte@Sun.COM }
124*7836SJohn.Forte@Sun.COM return (ret);
125*7836SJohn.Forte@Sun.COM
126*7836SJohn.Forte@Sun.COM }
127*7836SJohn.Forte@Sun.COM
128*7836SJohn.Forte@Sun.COM rdc_set_t
config2set(rdcconfig_t * rdc)129*7836SJohn.Forte@Sun.COM config2set(rdcconfig_t *rdc)
130*7836SJohn.Forte@Sun.COM {
131*7836SJohn.Forte@Sun.COM rdc_set_t urdc;
132*7836SJohn.Forte@Sun.COM
133*7836SJohn.Forte@Sun.COM bzero(&urdc, sizeof (rdc_set_t));
134*7836SJohn.Forte@Sun.COM strncpy(urdc.primary.intf, rdc->phost, MAX_RDC_HOST_SIZE);
135*7836SJohn.Forte@Sun.COM strncpy(urdc.primary.file, rdc->pfile, NSC_MAXPATH);
136*7836SJohn.Forte@Sun.COM strncpy(urdc.primary.bitmap, rdc->pbmp, NSC_MAXPATH);
137*7836SJohn.Forte@Sun.COM strncpy(urdc.secondary.intf, rdc->shost, MAX_RDC_HOST_SIZE);
138*7836SJohn.Forte@Sun.COM strncpy(urdc.secondary.file, rdc->sfile, NSC_MAXPATH);
139*7836SJohn.Forte@Sun.COM strncpy(urdc.secondary.bitmap, rdc->sbmp, NSC_MAXPATH);
140*7836SJohn.Forte@Sun.COM strncpy(urdc.group_name, rdc->group, NSC_MAXPATH);
141*7836SJohn.Forte@Sun.COM
142*7836SJohn.Forte@Sun.COM return (urdc);
143*7836SJohn.Forte@Sun.COM }
144*7836SJohn.Forte@Sun.COM
145*7836SJohn.Forte@Sun.COM rdc_rc_t *
new_rc()146*7836SJohn.Forte@Sun.COM new_rc()
147*7836SJohn.Forte@Sun.COM {
148*7836SJohn.Forte@Sun.COM rdc_rc_t *rc;
149*7836SJohn.Forte@Sun.COM
150*7836SJohn.Forte@Sun.COM rc = (rdc_rc_t *)calloc(1, sizeof (*rc));
151*7836SJohn.Forte@Sun.COM if (rc == NULL) {
152*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
153*7836SJohn.Forte@Sun.COM return (NULL);
154*7836SJohn.Forte@Sun.COM }
155*7836SJohn.Forte@Sun.COM return (rc);
156*7836SJohn.Forte@Sun.COM }
157*7836SJohn.Forte@Sun.COM
158*7836SJohn.Forte@Sun.COM rdc_rc_t
rdc_config(rdc_config_t * rdccfg)159*7836SJohn.Forte@Sun.COM rdc_config(rdc_config_t *rdccfg)
160*7836SJohn.Forte@Sun.COM {
161*7836SJohn.Forte@Sun.COM rdc_rc_t rc;
162*7836SJohn.Forte@Sun.COM rdc_set_t *set;
163*7836SJohn.Forte@Sun.COM spcs_s_info_t ustatus;
164*7836SJohn.Forte@Sun.COM
165*7836SJohn.Forte@Sun.COM bzero(&rc, sizeof (rc));
166*7836SJohn.Forte@Sun.COM ustatus = spcs_s_ucreate();
167*7836SJohn.Forte@Sun.COM
168*7836SJohn.Forte@Sun.COM if (self_check(rdccfg->rdc_set->primary.intf)) {
169*7836SJohn.Forte@Sun.COM rdccfg->options |= RDC_OPT_PRIMARY;
170*7836SJohn.Forte@Sun.COM /* this needs changin if we do campus */
171*7836SJohn.Forte@Sun.COM rdccfg->rdc_set->direct_file[0] = 0;
172*7836SJohn.Forte@Sun.COM } else {
173*7836SJohn.Forte@Sun.COM rdccfg->options |= RDC_OPT_SECONDARY;
174*7836SJohn.Forte@Sun.COM }
175*7836SJohn.Forte@Sun.COM
176*7836SJohn.Forte@Sun.COM /* set up return stuff.. */
177*7836SJohn.Forte@Sun.COM set = &rdccfg->rdc_set[0];
178*7836SJohn.Forte@Sun.COM strncpy(rc.set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
179*7836SJohn.Forte@Sun.COM strncpy(rc.set.pfile, set->primary.file, NSC_MAXPATH);
180*7836SJohn.Forte@Sun.COM strncpy(rc.set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
181*7836SJohn.Forte@Sun.COM strncpy(rc.set.sfile, set->secondary.file, NSC_MAXPATH);
182*7836SJohn.Forte@Sun.COM
183*7836SJohn.Forte@Sun.COM rc.rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
184*7836SJohn.Forte@Sun.COM
185*7836SJohn.Forte@Sun.COM if (rc.rc < 0) {
186*7836SJohn.Forte@Sun.COM rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
187*7836SJohn.Forte@Sun.COM strncpy(rc.msg, rdc_error(NULL), RDC_ERR_SIZE);
188*7836SJohn.Forte@Sun.COM }
189*7836SJohn.Forte@Sun.COM
190*7836SJohn.Forte@Sun.COM return (rc);
191*7836SJohn.Forte@Sun.COM }
192*7836SJohn.Forte@Sun.COM
193*7836SJohn.Forte@Sun.COM void *
rdc_mtconfig(void * rdc)194*7836SJohn.Forte@Sun.COM rdc_mtconfig(void *rdc)
195*7836SJohn.Forte@Sun.COM {
196*7836SJohn.Forte@Sun.COM rdc_rc_t *rc[1];
197*7836SJohn.Forte@Sun.COM rdc_set_t *set;
198*7836SJohn.Forte@Sun.COM spcs_s_info_t ustatus;
199*7836SJohn.Forte@Sun.COM rdc_config_t *rdccfg = (rdc_config_t *)rdc;
200*7836SJohn.Forte@Sun.COM
201*7836SJohn.Forte@Sun.COM ustatus = spcs_s_ucreate();
202*7836SJohn.Forte@Sun.COM
203*7836SJohn.Forte@Sun.COM if (self_check(rdccfg->rdc_set->primary.intf)) {
204*7836SJohn.Forte@Sun.COM rdccfg->options |= RDC_OPT_PRIMARY;
205*7836SJohn.Forte@Sun.COM /* this needs changin if we do campus */
206*7836SJohn.Forte@Sun.COM rdccfg->rdc_set->direct_file[0] = 0;
207*7836SJohn.Forte@Sun.COM } else {
208*7836SJohn.Forte@Sun.COM rdccfg->options |= RDC_OPT_SECONDARY;
209*7836SJohn.Forte@Sun.COM }
210*7836SJohn.Forte@Sun.COM
211*7836SJohn.Forte@Sun.COM set = &rdccfg->rdc_set[0];
212*7836SJohn.Forte@Sun.COM *rc = new_rc();
213*7836SJohn.Forte@Sun.COM
214*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
215*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.pfile, set->primary.file, NSC_MAXPATH);
216*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.pbmp, set->primary.bitmap, NSC_MAXPATH);
217*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
218*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.sfile, set->secondary.file, NSC_MAXPATH);
219*7836SJohn.Forte@Sun.COM strncpy(rc[0]->set.sbmp, set->secondary.bitmap, NSC_MAXPATH);
220*7836SJohn.Forte@Sun.COM
221*7836SJohn.Forte@Sun.COM rc[0]->rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
222*7836SJohn.Forte@Sun.COM
223*7836SJohn.Forte@Sun.COM if (rc[0]->rc < 0) {
224*7836SJohn.Forte@Sun.COM rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
225*7836SJohn.Forte@Sun.COM strncpy(rc[0]->msg, rdc_error(NULL), RDC_ERR_SIZE);
226*7836SJohn.Forte@Sun.COM }
227*7836SJohn.Forte@Sun.COM
228*7836SJohn.Forte@Sun.COM sleep(1); /* give thr_join a chance to be called */
229*7836SJohn.Forte@Sun.COM free(rdccfg);
230*7836SJohn.Forte@Sun.COM thr_exit((void **) *rc);
231*7836SJohn.Forte@Sun.COM return (NULL);
232*7836SJohn.Forte@Sun.COM }
233*7836SJohn.Forte@Sun.COM int
populate_addrs(rdc_set_t * urdc,int isenable)234*7836SJohn.Forte@Sun.COM populate_addrs(rdc_set_t *urdc, int isenable)
235*7836SJohn.Forte@Sun.COM {
236*7836SJohn.Forte@Sun.COM struct t_info tinfo;
237*7836SJohn.Forte@Sun.COM struct hostent *hp;
238*7836SJohn.Forte@Sun.COM char toname[MAX_RDC_HOST_SIZE];
239*7836SJohn.Forte@Sun.COM char fromname[MAX_RDC_HOST_SIZE];
240*7836SJohn.Forte@Sun.COM
241*7836SJohn.Forte@Sun.COM strncpy(fromname, urdc->primary.intf, MAX_RDC_HOST_SIZE);
242*7836SJohn.Forte@Sun.COM strncpy(toname, urdc->secondary.intf, MAX_RDC_HOST_SIZE);
243*7836SJohn.Forte@Sun.COM
244*7836SJohn.Forte@Sun.COM if ((fromname[0] == '\0') || (fromname[0] == '\0')) {
245*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL,
246*7836SJohn.Forte@Sun.COM "NULL hostname recieved");
247*7836SJohn.Forte@Sun.COM return (-1);
248*7836SJohn.Forte@Sun.COM }
249*7836SJohn.Forte@Sun.COM
250*7836SJohn.Forte@Sun.COM hp = gethost_byname(fromname);
251*7836SJohn.Forte@Sun.COM strncpy(fromname, hp->h_name, MAX_RDC_HOST_SIZE);
252*7836SJohn.Forte@Sun.COM hp = gethost_byname(toname);
253*7836SJohn.Forte@Sun.COM strncpy(toname, hp->h_name, MAX_RDC_HOST_SIZE);
254*7836SJohn.Forte@Sun.COM
255*7836SJohn.Forte@Sun.COM if (self_check(fromname) && self_check(toname)) {
256*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL, "");
257*7836SJohn.Forte@Sun.COM }
258*7836SJohn.Forte@Sun.COM
259*7836SJohn.Forte@Sun.COM if (isenable) {
260*7836SJohn.Forte@Sun.COM svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
261*7836SJohn.Forte@Sun.COM &conf, NULL, "rdc", &tinfo, 0);
262*7836SJohn.Forte@Sun.COM if (svp == NULL)
263*7836SJohn.Forte@Sun.COM return (-1);
264*7836SJohn.Forte@Sun.COM svaddr = *svp;
265*7836SJohn.Forte@Sun.COM } else {
266*7836SJohn.Forte@Sun.COM bzero(&svaddr, sizeof (svaddr));
267*7836SJohn.Forte@Sun.COM }
268*7836SJohn.Forte@Sun.COM
269*7836SJohn.Forte@Sun.COM urdc->secondary.addr.len = svaddr.len;
270*7836SJohn.Forte@Sun.COM urdc->secondary.addr.maxlen = svaddr.maxlen;
271*7836SJohn.Forte@Sun.COM urdc->secondary.addr.buf = (void*)svaddr.buf;
272*7836SJohn.Forte@Sun.COM
273*7836SJohn.Forte@Sun.COM if (isenable) {
274*7836SJohn.Forte@Sun.COM svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
275*7836SJohn.Forte@Sun.COM &conf, NULL, "rdc", &tinfo, 0);
276*7836SJohn.Forte@Sun.COM if (svp == NULL)
277*7836SJohn.Forte@Sun.COM return (-1);
278*7836SJohn.Forte@Sun.COM svaddr = *svp;
279*7836SJohn.Forte@Sun.COM } else {
280*7836SJohn.Forte@Sun.COM bzero(&svaddr, sizeof (svaddr));
281*7836SJohn.Forte@Sun.COM }
282*7836SJohn.Forte@Sun.COM
283*7836SJohn.Forte@Sun.COM urdc->primary.addr.len = svaddr.len;
284*7836SJohn.Forte@Sun.COM urdc->primary.addr.maxlen = svaddr.maxlen;
285*7836SJohn.Forte@Sun.COM urdc->primary.addr.buf = (void*)svaddr.buf;
286*7836SJohn.Forte@Sun.COM
287*7836SJohn.Forte@Sun.COM if (isenable) {
288*7836SJohn.Forte@Sun.COM convert_nconf_to_knconf(conf, &knconf);
289*7836SJohn.Forte@Sun.COM urdc->netconfig = &knconf;
290*7836SJohn.Forte@Sun.COM } else {
291*7836SJohn.Forte@Sun.COM urdc->netconfig = NULL;
292*7836SJohn.Forte@Sun.COM }
293*7836SJohn.Forte@Sun.COM urdc->syshostid = (int32_t)gethostid();
294*7836SJohn.Forte@Sun.COM
295*7836SJohn.Forte@Sun.COM return (1);
296*7836SJohn.Forte@Sun.COM
297*7836SJohn.Forte@Sun.COM }
298*7836SJohn.Forte@Sun.COM void
rdc_free_config(rdcconfig_t * rdc,int all)299*7836SJohn.Forte@Sun.COM rdc_free_config(rdcconfig_t *rdc, int all)
300*7836SJohn.Forte@Sun.COM {
301*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp;
302*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcq;
303*7836SJohn.Forte@Sun.COM
304*7836SJohn.Forte@Sun.COM rdcp = rdc;
305*7836SJohn.Forte@Sun.COM if (all == RDC_FREEONE) {
306*7836SJohn.Forte@Sun.COM free(rdcp);
307*7836SJohn.Forte@Sun.COM } else while (rdcp) {
308*7836SJohn.Forte@Sun.COM rdcq = rdcp->next;
309*7836SJohn.Forte@Sun.COM free(rdcp);
310*7836SJohn.Forte@Sun.COM rdcp = rdcq;
311*7836SJohn.Forte@Sun.COM }
312*7836SJohn.Forte@Sun.COM rdc = NULL;
313*7836SJohn.Forte@Sun.COM }
314*7836SJohn.Forte@Sun.COM
315*7836SJohn.Forte@Sun.COM void
rdc_free_rclist(rdc_rc_t * rc)316*7836SJohn.Forte@Sun.COM rdc_free_rclist(rdc_rc_t *rc) {
317*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp, *rcq;
318*7836SJohn.Forte@Sun.COM
319*7836SJohn.Forte@Sun.COM rcp = rc;
320*7836SJohn.Forte@Sun.COM while (rcp) {
321*7836SJohn.Forte@Sun.COM rcq = rcp->next;
322*7836SJohn.Forte@Sun.COM free(rcp);
323*7836SJohn.Forte@Sun.COM rcp = rcq;
324*7836SJohn.Forte@Sun.COM }
325*7836SJohn.Forte@Sun.COM
326*7836SJohn.Forte@Sun.COM }
327*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
328*7836SJohn.Forte@Sun.COM rdcconfig_t *
rdc_alloc_config(const char * phost,const char * pfile,const char * pbmp,const char * shost,const char * sfile,const char * sbmp,const char * mode,const char * group,const char * ctag,const char * options,int persist)329*7836SJohn.Forte@Sun.COM rdc_alloc_config(const char *phost, const char *pfile,
330*7836SJohn.Forte@Sun.COM const char *pbmp, const char *shost, const char *sfile, const char *sbmp,
331*7836SJohn.Forte@Sun.COM const char *mode, const char *group, const char *ctag, const char *options,
332*7836SJohn.Forte@Sun.COM int persist)
333*7836SJohn.Forte@Sun.COM {
334*7836SJohn.Forte@Sun.COM rdcconfig_t *rc;
335*7836SJohn.Forte@Sun.COM
336*7836SJohn.Forte@Sun.COM rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
337*7836SJohn.Forte@Sun.COM if (!rc) {
338*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
339*7836SJohn.Forte@Sun.COM return (NULL);
340*7836SJohn.Forte@Sun.COM }
341*7836SJohn.Forte@Sun.COM if (phost)
342*7836SJohn.Forte@Sun.COM strncpy(rc->phost, phost, NSC_MAXPATH);
343*7836SJohn.Forte@Sun.COM if (pfile)
344*7836SJohn.Forte@Sun.COM strncpy(rc->pfile, pfile, NSC_MAXPATH);
345*7836SJohn.Forte@Sun.COM if (pbmp)
346*7836SJohn.Forte@Sun.COM strncpy(rc->pbmp, pbmp, NSC_MAXPATH);
347*7836SJohn.Forte@Sun.COM if (shost)
348*7836SJohn.Forte@Sun.COM strncpy(rc->shost, shost, NSC_MAXPATH);
349*7836SJohn.Forte@Sun.COM if (sfile)
350*7836SJohn.Forte@Sun.COM strncpy(rc->sfile, sfile, NSC_MAXPATH);
351*7836SJohn.Forte@Sun.COM if (sbmp)
352*7836SJohn.Forte@Sun.COM strncpy(rc->sbmp, sbmp, NSC_MAXPATH);
353*7836SJohn.Forte@Sun.COM
354*7836SJohn.Forte@Sun.COM strncpy(rc->direct, "ip", 2);
355*7836SJohn.Forte@Sun.COM
356*7836SJohn.Forte@Sun.COM if (mode)
357*7836SJohn.Forte@Sun.COM strncpy(rc->mode, mode, NSC_MAXPATH);
358*7836SJohn.Forte@Sun.COM if (ctag)
359*7836SJohn.Forte@Sun.COM strncpy(rc->ctag, ctag, NSC_MAXPATH);
360*7836SJohn.Forte@Sun.COM if (options)
361*7836SJohn.Forte@Sun.COM strncpy(rc->options, options, NSC_MAXPATH);
362*7836SJohn.Forte@Sun.COM
363*7836SJohn.Forte@Sun.COM rc->persist = persist;
364*7836SJohn.Forte@Sun.COM rc->next = NULL;
365*7836SJohn.Forte@Sun.COM
366*7836SJohn.Forte@Sun.COM return (rc);
367*7836SJohn.Forte@Sun.COM
368*7836SJohn.Forte@Sun.COM }
369*7836SJohn.Forte@Sun.COM
370*7836SJohn.Forte@Sun.COM void
populate_rc(rdc_rc_t * rcp,rdcconfig_t * rdcp)371*7836SJohn.Forte@Sun.COM populate_rc(rdc_rc_t *rcp, rdcconfig_t *rdcp)
372*7836SJohn.Forte@Sun.COM {
373*7836SJohn.Forte@Sun.COM rcp->rc = -1;
374*7836SJohn.Forte@Sun.COM strncpy(rcp->msg, rdc_error(NULL), RDC_ERR_SIZE);
375*7836SJohn.Forte@Sun.COM strncpy(rcp->set.phost, rdcp->phost, NSC_MAXPATH);
376*7836SJohn.Forte@Sun.COM strncpy(rcp->set.pfile, rdcp->pfile, NSC_MAXPATH);
377*7836SJohn.Forte@Sun.COM strncpy(rcp->set.shost, rdcp->shost, NSC_MAXPATH);
378*7836SJohn.Forte@Sun.COM strncpy(rcp->set.sfile, rdcp->sfile, NSC_MAXPATH);
379*7836SJohn.Forte@Sun.COM }
380*7836SJohn.Forte@Sun.COM
381*7836SJohn.Forte@Sun.COM /*
382*7836SJohn.Forte@Sun.COM * rdc_enable
383*7836SJohn.Forte@Sun.COM * return values
384*7836SJohn.Forte@Sun.COM * NULL on error
385*7836SJohn.Forte@Sun.COM * pointer to rdc_rc_t list of return values
386*7836SJohn.Forte@Sun.COM */
387*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_enable(rdcconfig_t * rdc)388*7836SJohn.Forte@Sun.COM rdc_enable(rdcconfig_t *rdc)
389*7836SJohn.Forte@Sun.COM {
390*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
391*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
392*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
393*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
394*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
395*7836SJohn.Forte@Sun.COM
396*7836SJohn.Forte@Sun.COM rdcp = rdc;
397*7836SJohn.Forte@Sun.COM rc = new_rc();
398*7836SJohn.Forte@Sun.COM if (!rc) { /* error already set */
399*7836SJohn.Forte@Sun.COM return (NULL);
400*7836SJohn.Forte@Sun.COM }
401*7836SJohn.Forte@Sun.COM rcp = rc;
402*7836SJohn.Forte@Sun.COM while (rdcp) {
403*7836SJohn.Forte@Sun.COM if (!rdcp->mode) {
404*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
405*7836SJohn.Forte@Sun.COM RDC_EINVAL);
406*7836SJohn.Forte@Sun.COM return (NULL);
407*7836SJohn.Forte@Sun.COM }
408*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
409*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
410*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_ENABLE;
411*7836SJohn.Forte@Sun.COM rdccfg.options = RDC_OPT_SETBMP;
412*7836SJohn.Forte@Sun.COM if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
413*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_SYNC;
414*7836SJohn.Forte@Sun.COM } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
415*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_ASYNC;
416*7836SJohn.Forte@Sun.COM } else {
417*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
418*7836SJohn.Forte@Sun.COM RDC_EINVAL);
419*7836SJohn.Forte@Sun.COM return (NULL);
420*7836SJohn.Forte@Sun.COM }
421*7836SJohn.Forte@Sun.COM
422*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 1);
423*7836SJohn.Forte@Sun.COM
424*7836SJohn.Forte@Sun.COM if (can_enable(rdcp)) {
425*7836SJohn.Forte@Sun.COM /* do the operation */
426*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
427*7836SJohn.Forte@Sun.COM
428*7836SJohn.Forte@Sun.COM } else { /* set up what rdc_config would've set up */
429*7836SJohn.Forte@Sun.COM
430*7836SJohn.Forte@Sun.COM populate_rc(rcp, rdcp);
431*7836SJohn.Forte@Sun.COM
432*7836SJohn.Forte@Sun.COM }
433*7836SJohn.Forte@Sun.COM if ((rcp->rc == 0) && (!rdcp->persist)) {
434*7836SJohn.Forte@Sun.COM /*
435*7836SJohn.Forte@Sun.COM * if we are not persisting, do this now,
436*7836SJohn.Forte@Sun.COM * otherwise we will do it when
437*7836SJohn.Forte@Sun.COM * we have a lock on the cfg in add_to_rdc_cfg
438*7836SJohn.Forte@Sun.COM */
439*7836SJohn.Forte@Sun.COM sv_enable(NULL, rdcp);
440*7836SJohn.Forte@Sun.COM }
441*7836SJohn.Forte@Sun.COM
442*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
443*7836SJohn.Forte@Sun.COM if (!rdcp)
444*7836SJohn.Forte@Sun.COM break;
445*7836SJohn.Forte@Sun.COM
446*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
447*7836SJohn.Forte@Sun.COM rcp = rcp->next;
448*7836SJohn.Forte@Sun.COM if (!rcp) {
449*7836SJohn.Forte@Sun.COM /* dont free here, return what you have */
450*7836SJohn.Forte@Sun.COM break;
451*7836SJohn.Forte@Sun.COM }
452*7836SJohn.Forte@Sun.COM }
453*7836SJohn.Forte@Sun.COM
454*7836SJohn.Forte@Sun.COM /*
455*7836SJohn.Forte@Sun.COM * travel the rc chain and rdc chain checking results,
456*7836SJohn.Forte@Sun.COM * building a new chain, and updating dscfg
457*7836SJohn.Forte@Sun.COM */
458*7836SJohn.Forte@Sun.COM rcp = rc;
459*7836SJohn.Forte@Sun.COM rdcp = rdc;
460*7836SJohn.Forte@Sun.COM
461*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
462*7836SJohn.Forte@Sun.COM
463*7836SJohn.Forte@Sun.COM if (add_to_rdc_cfg(cfg_rdcs) < 0) {
464*7836SJohn.Forte@Sun.COM /* XXX should disable or something here */
465*7836SJohn.Forte@Sun.COM return (rc);
466*7836SJohn.Forte@Sun.COM }
467*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
468*7836SJohn.Forte@Sun.COM return (rc);
469*7836SJohn.Forte@Sun.COM
470*7836SJohn.Forte@Sun.COM }
471*7836SJohn.Forte@Sun.COM
472*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_enable_clrbmp(rdcconfig_t * rdc)473*7836SJohn.Forte@Sun.COM rdc_enable_clrbmp(rdcconfig_t *rdc)
474*7836SJohn.Forte@Sun.COM {
475*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
476*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
477*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
478*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
479*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
480*7836SJohn.Forte@Sun.COM
481*7836SJohn.Forte@Sun.COM rdcp = rdc;
482*7836SJohn.Forte@Sun.COM rc = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
483*7836SJohn.Forte@Sun.COM if (!rc) {
484*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
485*7836SJohn.Forte@Sun.COM return (NULL);
486*7836SJohn.Forte@Sun.COM }
487*7836SJohn.Forte@Sun.COM rcp = rc;
488*7836SJohn.Forte@Sun.COM while (rdcp) {
489*7836SJohn.Forte@Sun.COM if (!rdcp->mode) {
490*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
491*7836SJohn.Forte@Sun.COM RDC_EINVAL);
492*7836SJohn.Forte@Sun.COM return (NULL);
493*7836SJohn.Forte@Sun.COM }
494*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
495*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
496*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_ENABLE;
497*7836SJohn.Forte@Sun.COM rdccfg.options = RDC_OPT_CLRBMP;
498*7836SJohn.Forte@Sun.COM if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
499*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_SYNC;
500*7836SJohn.Forte@Sun.COM } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
501*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_ASYNC;
502*7836SJohn.Forte@Sun.COM } else {
503*7836SJohn.Forte@Sun.COM rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
504*7836SJohn.Forte@Sun.COM RDC_EINVAL);
505*7836SJohn.Forte@Sun.COM return (NULL);
506*7836SJohn.Forte@Sun.COM }
507*7836SJohn.Forte@Sun.COM
508*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 1);
509*7836SJohn.Forte@Sun.COM
510*7836SJohn.Forte@Sun.COM if (can_enable(rdcp)) {
511*7836SJohn.Forte@Sun.COM /* do the operation */
512*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
513*7836SJohn.Forte@Sun.COM
514*7836SJohn.Forte@Sun.COM } else { /* set up what rdc_config would've set up */
515*7836SJohn.Forte@Sun.COM
516*7836SJohn.Forte@Sun.COM populate_rc(rcp, rdcp);
517*7836SJohn.Forte@Sun.COM
518*7836SJohn.Forte@Sun.COM }
519*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
520*7836SJohn.Forte@Sun.COM if (!rdcp)
521*7836SJohn.Forte@Sun.COM break;
522*7836SJohn.Forte@Sun.COM
523*7836SJohn.Forte@Sun.COM rcp->next = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
524*7836SJohn.Forte@Sun.COM rcp = rcp->next;
525*7836SJohn.Forte@Sun.COM if (!rcp)
526*7836SJohn.Forte@Sun.COM break;
527*7836SJohn.Forte@Sun.COM }
528*7836SJohn.Forte@Sun.COM
529*7836SJohn.Forte@Sun.COM /*
530*7836SJohn.Forte@Sun.COM * travel the rc chain and rdc chain checking results,
531*7836SJohn.Forte@Sun.COM * building a new chain, and updating dscfg
532*7836SJohn.Forte@Sun.COM */
533*7836SJohn.Forte@Sun.COM rcp = rc;
534*7836SJohn.Forte@Sun.COM rdcp = rdc;
535*7836SJohn.Forte@Sun.COM
536*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
537*7836SJohn.Forte@Sun.COM
538*7836SJohn.Forte@Sun.COM if (add_to_rdc_cfg(cfg_rdcs) < 0) {
539*7836SJohn.Forte@Sun.COM /* XXX should disable or something here */
540*7836SJohn.Forte@Sun.COM return (rc);
541*7836SJohn.Forte@Sun.COM }
542*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
543*7836SJohn.Forte@Sun.COM
544*7836SJohn.Forte@Sun.COM return (rc);
545*7836SJohn.Forte@Sun.COM
546*7836SJohn.Forte@Sun.COM }
547*7836SJohn.Forte@Sun.COM
548*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_disable(rdcconfig_t * rdc)549*7836SJohn.Forte@Sun.COM rdc_disable(rdcconfig_t *rdc)
550*7836SJohn.Forte@Sun.COM {
551*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
552*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
553*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
554*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
555*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
556*7836SJohn.Forte@Sun.COM
557*7836SJohn.Forte@Sun.COM rdcp = rdc;
558*7836SJohn.Forte@Sun.COM rc = new_rc();
559*7836SJohn.Forte@Sun.COM if (!rc) {
560*7836SJohn.Forte@Sun.COM return (NULL);
561*7836SJohn.Forte@Sun.COM }
562*7836SJohn.Forte@Sun.COM rcp = rc;
563*7836SJohn.Forte@Sun.COM
564*7836SJohn.Forte@Sun.COM while (rdcp) {
565*7836SJohn.Forte@Sun.COM
566*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
567*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
568*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_DISABLE;
569*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
570*7836SJohn.Forte@Sun.COM
571*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
572*7836SJohn.Forte@Sun.COM
573*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
574*7836SJohn.Forte@Sun.COM if (!rdcp)
575*7836SJohn.Forte@Sun.COM break;
576*7836SJohn.Forte@Sun.COM
577*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
578*7836SJohn.Forte@Sun.COM rcp = rcp->next;
579*7836SJohn.Forte@Sun.COM if (!rcp)
580*7836SJohn.Forte@Sun.COM return (rc);
581*7836SJohn.Forte@Sun.COM
582*7836SJohn.Forte@Sun.COM }
583*7836SJohn.Forte@Sun.COM rcp = rc;
584*7836SJohn.Forte@Sun.COM rdcp = rdc;
585*7836SJohn.Forte@Sun.COM
586*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
587*7836SJohn.Forte@Sun.COM
588*7836SJohn.Forte@Sun.COM remove_from_rdc_cfg(cfg_rdcs);
589*7836SJohn.Forte@Sun.COM
590*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
591*7836SJohn.Forte@Sun.COM
592*7836SJohn.Forte@Sun.COM return (rc);
593*7836SJohn.Forte@Sun.COM }
594*7836SJohn.Forte@Sun.COM
595*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_log(rdcconfig_t * rdc)596*7836SJohn.Forte@Sun.COM rdc_log(rdcconfig_t *rdc)
597*7836SJohn.Forte@Sun.COM {
598*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
599*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
600*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
601*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
602*7836SJohn.Forte@Sun.COM
603*7836SJohn.Forte@Sun.COM rdcp = rdc;
604*7836SJohn.Forte@Sun.COM rc = new_rc();
605*7836SJohn.Forte@Sun.COM if (!rc) {
606*7836SJohn.Forte@Sun.COM return (NULL);
607*7836SJohn.Forte@Sun.COM }
608*7836SJohn.Forte@Sun.COM rcp = rc;
609*7836SJohn.Forte@Sun.COM
610*7836SJohn.Forte@Sun.COM while (rdcp) {
611*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
612*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
613*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_LOG;
614*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
615*7836SJohn.Forte@Sun.COM
616*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
617*7836SJohn.Forte@Sun.COM
618*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
619*7836SJohn.Forte@Sun.COM if (!rdcp)
620*7836SJohn.Forte@Sun.COM break;
621*7836SJohn.Forte@Sun.COM
622*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
623*7836SJohn.Forte@Sun.COM rcp = rcp->next;
624*7836SJohn.Forte@Sun.COM if (!rcp)
625*7836SJohn.Forte@Sun.COM break;
626*7836SJohn.Forte@Sun.COM }
627*7836SJohn.Forte@Sun.COM return (rc);
628*7836SJohn.Forte@Sun.COM }
629*7836SJohn.Forte@Sun.COM
630*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_usync(rdcconfig_t * rdc)631*7836SJohn.Forte@Sun.COM rdc_usync(rdcconfig_t *rdc)
632*7836SJohn.Forte@Sun.COM {
633*7836SJohn.Forte@Sun.COM rdc_config_t *rdccfg;
634*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
635*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
636*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
637*7836SJohn.Forte@Sun.COM rdc_rc_t *tmprc;
638*7836SJohn.Forte@Sun.COM int trc;
639*7836SJohn.Forte@Sun.COM
640*7836SJohn.Forte@Sun.COM rdcp = rdc;
641*7836SJohn.Forte@Sun.COM
642*7836SJohn.Forte@Sun.COM while (rdcp) {
643*7836SJohn.Forte@Sun.COM /* freed in rdc_mtconfig */
644*7836SJohn.Forte@Sun.COM rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
645*7836SJohn.Forte@Sun.COM rdccfg->rdc_set[0] = config2set(rdcp);
646*7836SJohn.Forte@Sun.COM rdccfg->command = RDC_CMD_COPY;
647*7836SJohn.Forte@Sun.COM rdccfg->options = RDC_OPT_UPDATE|RDC_OPT_FORWARD;
648*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg->rdc_set[0], 0);
649*7836SJohn.Forte@Sun.COM trc = thr_create(NULL, 0, rdc_mtconfig,
650*7836SJohn.Forte@Sun.COM (void **) rdccfg, THR_BOUND, NULL);
651*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
652*7836SJohn.Forte@Sun.COM if (!rdcp)
653*7836SJohn.Forte@Sun.COM break;
654*7836SJohn.Forte@Sun.COM
655*7836SJohn.Forte@Sun.COM }
656*7836SJohn.Forte@Sun.COM
657*7836SJohn.Forte@Sun.COM /*
658*7836SJohn.Forte@Sun.COM * collect status here from thr_join-status,
659*7836SJohn.Forte@Sun.COM * and add to rdc_rc_t chain ?
660*7836SJohn.Forte@Sun.COM * this will block, but caller could always thread too
661*7836SJohn.Forte@Sun.COM */
662*7836SJohn.Forte@Sun.COM while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
663*7836SJohn.Forte@Sun.COM if (rc == NULL) {
664*7836SJohn.Forte@Sun.COM rcp = rc = (rdc_rc_t *)tmprc;
665*7836SJohn.Forte@Sun.COM } else {
666*7836SJohn.Forte@Sun.COM rcp->next = (rdc_rc_t *)tmprc;
667*7836SJohn.Forte@Sun.COM rcp = rcp->next;
668*7836SJohn.Forte@Sun.COM }
669*7836SJohn.Forte@Sun.COM }
670*7836SJohn.Forte@Sun.COM
671*7836SJohn.Forte@Sun.COM return (rc);
672*7836SJohn.Forte@Sun.COM }
673*7836SJohn.Forte@Sun.COM
674*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_fsync(rdcconfig_t * rdc)675*7836SJohn.Forte@Sun.COM rdc_fsync(rdcconfig_t *rdc)
676*7836SJohn.Forte@Sun.COM {
677*7836SJohn.Forte@Sun.COM rdc_config_t *rdccfg;
678*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
679*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
680*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
681*7836SJohn.Forte@Sun.COM rdc_rc_t *tmprc = NULL;
682*7836SJohn.Forte@Sun.COM int trc;
683*7836SJohn.Forte@Sun.COM
684*7836SJohn.Forte@Sun.COM rdcp = rdc;
685*7836SJohn.Forte@Sun.COM rc = new_rc();
686*7836SJohn.Forte@Sun.COM if (!rc) {
687*7836SJohn.Forte@Sun.COM return (NULL);
688*7836SJohn.Forte@Sun.COM }
689*7836SJohn.Forte@Sun.COM rcp = rc;
690*7836SJohn.Forte@Sun.COM
691*7836SJohn.Forte@Sun.COM while (rdcp) {
692*7836SJohn.Forte@Sun.COM /* freed in rdc_mtconfig */
693*7836SJohn.Forte@Sun.COM rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
694*7836SJohn.Forte@Sun.COM rdccfg->rdc_set[0] = config2set(rdcp);
695*7836SJohn.Forte@Sun.COM rdccfg->command = RDC_CMD_COPY;
696*7836SJohn.Forte@Sun.COM rdccfg->options = RDC_OPT_FULL|RDC_OPT_FORWARD;
697*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg->rdc_set[0], 0);
698*7836SJohn.Forte@Sun.COM trc = thr_create(NULL, 0, rdc_mtconfig,
699*7836SJohn.Forte@Sun.COM (void **) rdccfg, THR_BOUND, NULL);
700*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
701*7836SJohn.Forte@Sun.COM if (!rdcp)
702*7836SJohn.Forte@Sun.COM break;
703*7836SJohn.Forte@Sun.COM
704*7836SJohn.Forte@Sun.COM }
705*7836SJohn.Forte@Sun.COM
706*7836SJohn.Forte@Sun.COM /*
707*7836SJohn.Forte@Sun.COM * collect status here from thr_join-status,
708*7836SJohn.Forte@Sun.COM * and add to rdc_rc_t chain ?
709*7836SJohn.Forte@Sun.COM * this will block, but caller could always thread too
710*7836SJohn.Forte@Sun.COM */
711*7836SJohn.Forte@Sun.COM while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
712*7836SJohn.Forte@Sun.COM if (rc == NULL) {
713*7836SJohn.Forte@Sun.COM rcp = rc = (rdc_rc_t *)tmprc;
714*7836SJohn.Forte@Sun.COM } else {
715*7836SJohn.Forte@Sun.COM rcp->next = (rdc_rc_t *)tmprc;
716*7836SJohn.Forte@Sun.COM rcp = rcp->next;
717*7836SJohn.Forte@Sun.COM }
718*7836SJohn.Forte@Sun.COM }
719*7836SJohn.Forte@Sun.COM
720*7836SJohn.Forte@Sun.COM return (rc);
721*7836SJohn.Forte@Sun.COM }
722*7836SJohn.Forte@Sun.COM
723*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_rsync(rdcconfig_t * rdc)724*7836SJohn.Forte@Sun.COM rdc_rsync(rdcconfig_t *rdc)
725*7836SJohn.Forte@Sun.COM {
726*7836SJohn.Forte@Sun.COM rdc_config_t *rdccfg;
727*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
728*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
729*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
730*7836SJohn.Forte@Sun.COM rdc_rc_t *tmprc = NULL;
731*7836SJohn.Forte@Sun.COM int trc;
732*7836SJohn.Forte@Sun.COM
733*7836SJohn.Forte@Sun.COM rdcp = rdc;
734*7836SJohn.Forte@Sun.COM rc = new_rc();
735*7836SJohn.Forte@Sun.COM if (!rc) {
736*7836SJohn.Forte@Sun.COM return (NULL);
737*7836SJohn.Forte@Sun.COM }
738*7836SJohn.Forte@Sun.COM rcp = rc;
739*7836SJohn.Forte@Sun.COM
740*7836SJohn.Forte@Sun.COM while (rdcp) {
741*7836SJohn.Forte@Sun.COM tmprc = cant_rsync(rdcp);
742*7836SJohn.Forte@Sun.COM if (tmprc != NULL) {
743*7836SJohn.Forte@Sun.COM if (rc == NULL) {
744*7836SJohn.Forte@Sun.COM rcp = rc = tmprc;
745*7836SJohn.Forte@Sun.COM } else {
746*7836SJohn.Forte@Sun.COM rcp->next = tmprc;
747*7836SJohn.Forte@Sun.COM rcp = rcp->next;
748*7836SJohn.Forte@Sun.COM }
749*7836SJohn.Forte@Sun.COM goto next;
750*7836SJohn.Forte@Sun.COM }
751*7836SJohn.Forte@Sun.COM
752*7836SJohn.Forte@Sun.COM /* freed in rdc_mtconfig */
753*7836SJohn.Forte@Sun.COM rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
754*7836SJohn.Forte@Sun.COM rdccfg->rdc_set[0] = config2set(rdcp);
755*7836SJohn.Forte@Sun.COM rdccfg->command = RDC_CMD_COPY;
756*7836SJohn.Forte@Sun.COM rdccfg->options = RDC_OPT_REVERSE|RDC_OPT_FULL;
757*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg->rdc_set[0], 0);
758*7836SJohn.Forte@Sun.COM trc = thr_create(NULL, 0, rdc_mtconfig,
759*7836SJohn.Forte@Sun.COM (void **) rdccfg, THR_BOUND, NULL);
760*7836SJohn.Forte@Sun.COM next:
761*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
762*7836SJohn.Forte@Sun.COM if (!rdcp)
763*7836SJohn.Forte@Sun.COM break;
764*7836SJohn.Forte@Sun.COM }
765*7836SJohn.Forte@Sun.COM
766*7836SJohn.Forte@Sun.COM /*
767*7836SJohn.Forte@Sun.COM * collect status here from thr_join-status,
768*7836SJohn.Forte@Sun.COM * and add to rdc_rc_t chain ?
769*7836SJohn.Forte@Sun.COM * this will block, but caller could always thread too
770*7836SJohn.Forte@Sun.COM */
771*7836SJohn.Forte@Sun.COM while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
772*7836SJohn.Forte@Sun.COM if (rc == NULL) {
773*7836SJohn.Forte@Sun.COM rcp = rc = (rdc_rc_t *)tmprc;
774*7836SJohn.Forte@Sun.COM } else {
775*7836SJohn.Forte@Sun.COM rcp->next = (rdc_rc_t *)tmprc;
776*7836SJohn.Forte@Sun.COM rcp = rcp->next;
777*7836SJohn.Forte@Sun.COM }
778*7836SJohn.Forte@Sun.COM }
779*7836SJohn.Forte@Sun.COM
780*7836SJohn.Forte@Sun.COM return (rc);
781*7836SJohn.Forte@Sun.COM }
782*7836SJohn.Forte@Sun.COM
783*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_ursync(rdcconfig_t * rdc)784*7836SJohn.Forte@Sun.COM rdc_ursync(rdcconfig_t *rdc)
785*7836SJohn.Forte@Sun.COM {
786*7836SJohn.Forte@Sun.COM rdc_config_t *rdccfg;
787*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
788*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
789*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
790*7836SJohn.Forte@Sun.COM rdc_rc_t *tmprc = NULL;
791*7836SJohn.Forte@Sun.COM int trc;
792*7836SJohn.Forte@Sun.COM
793*7836SJohn.Forte@Sun.COM rdcp = rdc;
794*7836SJohn.Forte@Sun.COM
795*7836SJohn.Forte@Sun.COM while (rdcp) {
796*7836SJohn.Forte@Sun.COM tmprc = cant_rsync(rdcp);
797*7836SJohn.Forte@Sun.COM if (tmprc != NULL) {
798*7836SJohn.Forte@Sun.COM if (rc == NULL) {
799*7836SJohn.Forte@Sun.COM rcp = rc = tmprc;
800*7836SJohn.Forte@Sun.COM } else {
801*7836SJohn.Forte@Sun.COM rcp->next = tmprc;
802*7836SJohn.Forte@Sun.COM rcp = rcp->next;
803*7836SJohn.Forte@Sun.COM }
804*7836SJohn.Forte@Sun.COM goto next;
805*7836SJohn.Forte@Sun.COM }
806*7836SJohn.Forte@Sun.COM
807*7836SJohn.Forte@Sun.COM /* freed in rdc_mtconfig */
808*7836SJohn.Forte@Sun.COM rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
809*7836SJohn.Forte@Sun.COM rdccfg->rdc_set[0] = config2set(rdcp);
810*7836SJohn.Forte@Sun.COM rdccfg->command = RDC_CMD_COPY;
811*7836SJohn.Forte@Sun.COM rdccfg->options = RDC_OPT_REVERSE | RDC_OPT_UPDATE;
812*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg->rdc_set[0], 0);
813*7836SJohn.Forte@Sun.COM trc = thr_create(NULL, 0, rdc_mtconfig,
814*7836SJohn.Forte@Sun.COM (void **) rdccfg, THR_BOUND, NULL);
815*7836SJohn.Forte@Sun.COM next:
816*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
817*7836SJohn.Forte@Sun.COM if (!rdcp)
818*7836SJohn.Forte@Sun.COM break;
819*7836SJohn.Forte@Sun.COM
820*7836SJohn.Forte@Sun.COM }
821*7836SJohn.Forte@Sun.COM
822*7836SJohn.Forte@Sun.COM /*
823*7836SJohn.Forte@Sun.COM * collect status here from thr_join-status,
824*7836SJohn.Forte@Sun.COM * and add to rdc_rc_t chain ?
825*7836SJohn.Forte@Sun.COM * this will block, but caller could always thread too
826*7836SJohn.Forte@Sun.COM */
827*7836SJohn.Forte@Sun.COM while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
828*7836SJohn.Forte@Sun.COM if (rc == NULL) {
829*7836SJohn.Forte@Sun.COM rcp = rc = (rdc_rc_t *)tmprc;
830*7836SJohn.Forte@Sun.COM } else {
831*7836SJohn.Forte@Sun.COM rcp->next = (rdc_rc_t *)tmprc;
832*7836SJohn.Forte@Sun.COM rcp = rcp->next;
833*7836SJohn.Forte@Sun.COM }
834*7836SJohn.Forte@Sun.COM }
835*7836SJohn.Forte@Sun.COM
836*7836SJohn.Forte@Sun.COM return (rc);
837*7836SJohn.Forte@Sun.COM }
838*7836SJohn.Forte@Sun.COM
839*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_wait(rdcconfig_t * rdc)840*7836SJohn.Forte@Sun.COM rdc_wait(rdcconfig_t *rdc)
841*7836SJohn.Forte@Sun.COM {
842*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
843*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
844*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
845*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
846*7836SJohn.Forte@Sun.COM
847*7836SJohn.Forte@Sun.COM rdcp = rdc;
848*7836SJohn.Forte@Sun.COM rc = new_rc();
849*7836SJohn.Forte@Sun.COM if (!rc) {
850*7836SJohn.Forte@Sun.COM return (NULL);
851*7836SJohn.Forte@Sun.COM }
852*7836SJohn.Forte@Sun.COM rcp = rc;
853*7836SJohn.Forte@Sun.COM
854*7836SJohn.Forte@Sun.COM while (rdcp) {
855*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
856*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
857*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_WAIT;
858*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
859*7836SJohn.Forte@Sun.COM
860*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
861*7836SJohn.Forte@Sun.COM
862*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
863*7836SJohn.Forte@Sun.COM if (!rdcp)
864*7836SJohn.Forte@Sun.COM break;
865*7836SJohn.Forte@Sun.COM
866*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
867*7836SJohn.Forte@Sun.COM rcp = rcp->next;
868*7836SJohn.Forte@Sun.COM if (!rcp)
869*7836SJohn.Forte@Sun.COM break;
870*7836SJohn.Forte@Sun.COM }
871*7836SJohn.Forte@Sun.COM return (rc);
872*7836SJohn.Forte@Sun.COM }
873*7836SJohn.Forte@Sun.COM
874*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_set_autosync(rdcconfig_t * rdc,int autosync)875*7836SJohn.Forte@Sun.COM rdc_set_autosync(rdcconfig_t *rdc, int autosync)
876*7836SJohn.Forte@Sun.COM {
877*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
878*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
879*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
880*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
881*7836SJohn.Forte@Sun.COM
882*7836SJohn.Forte@Sun.COM rdcp = rdc;
883*7836SJohn.Forte@Sun.COM rc = new_rc();
884*7836SJohn.Forte@Sun.COM if (!rc) {
885*7836SJohn.Forte@Sun.COM return (NULL);
886*7836SJohn.Forte@Sun.COM }
887*7836SJohn.Forte@Sun.COM rcp = rc;
888*7836SJohn.Forte@Sun.COM
889*7836SJohn.Forte@Sun.COM while (rdcp) {
890*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
891*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
892*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_TUNABLE;
893*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].autosync = autosync;
894*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqitems = -1;
895*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqfbas = -1;
896*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
897*7836SJohn.Forte@Sun.COM
898*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
899*7836SJohn.Forte@Sun.COM
900*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
901*7836SJohn.Forte@Sun.COM if (!rdcp)
902*7836SJohn.Forte@Sun.COM break;
903*7836SJohn.Forte@Sun.COM
904*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
905*7836SJohn.Forte@Sun.COM rcp = rcp->next;
906*7836SJohn.Forte@Sun.COM if (!rcp)
907*7836SJohn.Forte@Sun.COM break;
908*7836SJohn.Forte@Sun.COM }
909*7836SJohn.Forte@Sun.COM return (rc);
910*7836SJohn.Forte@Sun.COM }
911*7836SJohn.Forte@Sun.COM
912*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_set_maxqfbas(rdcconfig_t * rdc,int maxqfbas)913*7836SJohn.Forte@Sun.COM rdc_set_maxqfbas(rdcconfig_t *rdc, int maxqfbas)
914*7836SJohn.Forte@Sun.COM {
915*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
916*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
917*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
918*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
919*7836SJohn.Forte@Sun.COM
920*7836SJohn.Forte@Sun.COM rdcp = rdc;
921*7836SJohn.Forte@Sun.COM rc = new_rc();
922*7836SJohn.Forte@Sun.COM if (!rc) {
923*7836SJohn.Forte@Sun.COM return (NULL);
924*7836SJohn.Forte@Sun.COM }
925*7836SJohn.Forte@Sun.COM rcp = rc;
926*7836SJohn.Forte@Sun.COM
927*7836SJohn.Forte@Sun.COM while (rdcp) {
928*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
929*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
930*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_TUNABLE;
931*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].autosync = -1;
932*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqitems = -1;
933*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqfbas = maxqfbas;
934*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
935*7836SJohn.Forte@Sun.COM
936*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
937*7836SJohn.Forte@Sun.COM
938*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
939*7836SJohn.Forte@Sun.COM if (!rdcp)
940*7836SJohn.Forte@Sun.COM break;
941*7836SJohn.Forte@Sun.COM
942*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
943*7836SJohn.Forte@Sun.COM rcp = rcp->next;
944*7836SJohn.Forte@Sun.COM if (!rcp)
945*7836SJohn.Forte@Sun.COM break;
946*7836SJohn.Forte@Sun.COM }
947*7836SJohn.Forte@Sun.COM return (rc);
948*7836SJohn.Forte@Sun.COM }
949*7836SJohn.Forte@Sun.COM
950*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_set_maxqitems(rdcconfig_t * rdc,int maxqitems)951*7836SJohn.Forte@Sun.COM rdc_set_maxqitems(rdcconfig_t *rdc, int maxqitems)
952*7836SJohn.Forte@Sun.COM {
953*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
954*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
955*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
956*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
957*7836SJohn.Forte@Sun.COM
958*7836SJohn.Forte@Sun.COM rdcp = rdc;
959*7836SJohn.Forte@Sun.COM rc = new_rc();
960*7836SJohn.Forte@Sun.COM
961*7836SJohn.Forte@Sun.COM if (!rc) {
962*7836SJohn.Forte@Sun.COM return (NULL);
963*7836SJohn.Forte@Sun.COM }
964*7836SJohn.Forte@Sun.COM rcp = rc;
965*7836SJohn.Forte@Sun.COM
966*7836SJohn.Forte@Sun.COM while (rdcp) {
967*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
968*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdc);
969*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_TUNABLE;
970*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].autosync = -1;
971*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqitems = maxqitems;
972*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0].maxqfbas = -1;
973*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
974*7836SJohn.Forte@Sun.COM
975*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
976*7836SJohn.Forte@Sun.COM
977*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
978*7836SJohn.Forte@Sun.COM if (!rdcp)
979*7836SJohn.Forte@Sun.COM break;
980*7836SJohn.Forte@Sun.COM
981*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
982*7836SJohn.Forte@Sun.COM rcp = rcp->next;
983*7836SJohn.Forte@Sun.COM if (!rcp)
984*7836SJohn.Forte@Sun.COM break;
985*7836SJohn.Forte@Sun.COM }
986*7836SJohn.Forte@Sun.COM return (rc);
987*7836SJohn.Forte@Sun.COM }
988*7836SJohn.Forte@Sun.COM
989*7836SJohn.Forte@Sun.COM rdc_set_t
rdc_status(rdcconfig_t * rdc)990*7836SJohn.Forte@Sun.COM rdc_status(rdcconfig_t *rdc)
991*7836SJohn.Forte@Sun.COM {
992*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
993*7836SJohn.Forte@Sun.COM
994*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
995*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdc);
996*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_STATUS;
997*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
998*7836SJohn.Forte@Sun.COM rdc_config(&rdccfg);
999*7836SJohn.Forte@Sun.COM
1000*7836SJohn.Forte@Sun.COM return (rdccfg.rdc_set[0]);
1001*7836SJohn.Forte@Sun.COM }
1002*7836SJohn.Forte@Sun.COM
1003*7836SJohn.Forte@Sun.COM int
rdc_get_autosync(rdcconfig_t * rdc)1004*7836SJohn.Forte@Sun.COM rdc_get_autosync(rdcconfig_t *rdc)
1005*7836SJohn.Forte@Sun.COM {
1006*7836SJohn.Forte@Sun.COM rdc_set_t rdcset;
1007*7836SJohn.Forte@Sun.COM
1008*7836SJohn.Forte@Sun.COM rdcset = rdc_status(rdc);
1009*7836SJohn.Forte@Sun.COM return (rdcset.autosync);
1010*7836SJohn.Forte@Sun.COM }
1011*7836SJohn.Forte@Sun.COM
1012*7836SJohn.Forte@Sun.COM int
rdc_get_maxqfbas(rdcconfig_t * rdc)1013*7836SJohn.Forte@Sun.COM rdc_get_maxqfbas(rdcconfig_t *rdc)
1014*7836SJohn.Forte@Sun.COM {
1015*7836SJohn.Forte@Sun.COM rdc_set_t rdcset;
1016*7836SJohn.Forte@Sun.COM
1017*7836SJohn.Forte@Sun.COM rdcset = rdc_status(rdc);
1018*7836SJohn.Forte@Sun.COM return (rdcset.maxqfbas);
1019*7836SJohn.Forte@Sun.COM
1020*7836SJohn.Forte@Sun.COM }
1021*7836SJohn.Forte@Sun.COM
1022*7836SJohn.Forte@Sun.COM int
rdc_get_maxqitems(rdcconfig_t * rdc)1023*7836SJohn.Forte@Sun.COM rdc_get_maxqitems(rdcconfig_t *rdc)
1024*7836SJohn.Forte@Sun.COM {
1025*7836SJohn.Forte@Sun.COM rdc_set_t rdcset;
1026*7836SJohn.Forte@Sun.COM
1027*7836SJohn.Forte@Sun.COM rdcset = rdc_status(rdc);
1028*7836SJohn.Forte@Sun.COM return (rdcset.maxqitems);
1029*7836SJohn.Forte@Sun.COM
1030*7836SJohn.Forte@Sun.COM }
1031*7836SJohn.Forte@Sun.COM
1032*7836SJohn.Forte@Sun.COM int
set_mode(rdcconfig_t * rdc)1033*7836SJohn.Forte@Sun.COM set_mode(rdcconfig_t *rdc)
1034*7836SJohn.Forte@Sun.COM {
1035*7836SJohn.Forte@Sun.COM if (strcmp(rdc->mode, "async") == 0)
1036*7836SJohn.Forte@Sun.COM return (RDC_OPT_ASYNC);
1037*7836SJohn.Forte@Sun.COM else
1038*7836SJohn.Forte@Sun.COM return (RDC_OPT_SYNC);
1039*7836SJohn.Forte@Sun.COM }
1040*7836SJohn.Forte@Sun.COM
1041*7836SJohn.Forte@Sun.COM /*
1042*7836SJohn.Forte@Sun.COM * reconfig bitmaps are single set only ops
1043*7836SJohn.Forte@Sun.COM * for obvious reasons
1044*7836SJohn.Forte@Sun.COM */
1045*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_reconfig_pbmp(rdcconfig_t * rdc,char * pbmp)1046*7836SJohn.Forte@Sun.COM rdc_reconfig_pbmp(rdcconfig_t *rdc, char *pbmp)
1047*7836SJohn.Forte@Sun.COM {
1048*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1049*7836SJohn.Forte@Sun.COM rdc_rc_t *rc;
1050*7836SJohn.Forte@Sun.COM
1051*7836SJohn.Forte@Sun.COM rc = new_rc();
1052*7836SJohn.Forte@Sun.COM if ((!rc) || (!pbmp))
1053*7836SJohn.Forte@Sun.COM return (NULL);
1054*7836SJohn.Forte@Sun.COM
1055*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1056*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdc);
1057*7836SJohn.Forte@Sun.COM strncpy(rdccfg.rdc_set[0].primary.bitmap, pbmp, NSC_MAXPATH);
1058*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1059*7836SJohn.Forte@Sun.COM rdccfg.options |= set_mode(rdc);
1060*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1061*7836SJohn.Forte@Sun.COM
1062*7836SJohn.Forte@Sun.COM if (can_reconfig_pbmp(rdc, pbmp))
1063*7836SJohn.Forte@Sun.COM *rc = rdc_config(&rdccfg);
1064*7836SJohn.Forte@Sun.COM else
1065*7836SJohn.Forte@Sun.COM populate_rc(rc, rdc);
1066*7836SJohn.Forte@Sun.COM
1067*7836SJohn.Forte@Sun.COM if ((rc->rc == 0) && (rdc->persist))
1068*7836SJohn.Forte@Sun.COM if (replace_cfgfield(rdc, "pbitmap", pbmp) < 0) {
1069*7836SJohn.Forte@Sun.COM rc->rc = -1;
1070*7836SJohn.Forte@Sun.COM strncpy(rc->msg, rdc_error(NULL), RDC_ERR_SIZE);
1071*7836SJohn.Forte@Sun.COM }
1072*7836SJohn.Forte@Sun.COM return (rc);
1073*7836SJohn.Forte@Sun.COM }
1074*7836SJohn.Forte@Sun.COM
1075*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_reconfig_sbmp(rdcconfig_t * rdc,char * sbmp)1076*7836SJohn.Forte@Sun.COM rdc_reconfig_sbmp(rdcconfig_t *rdc, char *sbmp)
1077*7836SJohn.Forte@Sun.COM {
1078*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1079*7836SJohn.Forte@Sun.COM rdc_rc_t *rc;
1080*7836SJohn.Forte@Sun.COM
1081*7836SJohn.Forte@Sun.COM rc = new_rc();
1082*7836SJohn.Forte@Sun.COM if (!rc)
1083*7836SJohn.Forte@Sun.COM return (NULL);
1084*7836SJohn.Forte@Sun.COM
1085*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1086*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdc);
1087*7836SJohn.Forte@Sun.COM strncpy(rdccfg.rdc_set[0].secondary.bitmap, sbmp, NSC_MAXPATH);
1088*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1089*7836SJohn.Forte@Sun.COM rdccfg.options |= set_mode(rdc);
1090*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1091*7836SJohn.Forte@Sun.COM
1092*7836SJohn.Forte@Sun.COM if (can_reconfig_sbmp(rdc, sbmp))
1093*7836SJohn.Forte@Sun.COM *rc = rdc_config(&rdccfg);
1094*7836SJohn.Forte@Sun.COM else
1095*7836SJohn.Forte@Sun.COM populate_rc(rc, rdc);
1096*7836SJohn.Forte@Sun.COM
1097*7836SJohn.Forte@Sun.COM if ((rc->rc == 0) && (rdc->persist))
1098*7836SJohn.Forte@Sun.COM replace_cfgfield(rdc, "sbitmap", sbmp);
1099*7836SJohn.Forte@Sun.COM
1100*7836SJohn.Forte@Sun.COM return (rc);
1101*7836SJohn.Forte@Sun.COM }
1102*7836SJohn.Forte@Sun.COM
1103*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_reconfig_group(rdcconfig_t * rdc,char * group)1104*7836SJohn.Forte@Sun.COM rdc_reconfig_group(rdcconfig_t *rdc, char *group)
1105*7836SJohn.Forte@Sun.COM {
1106*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1107*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
1108*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
1109*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
1110*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
1111*7836SJohn.Forte@Sun.COM
1112*7836SJohn.Forte@Sun.COM rdcp = rdc;
1113*7836SJohn.Forte@Sun.COM rc = new_rc();
1114*7836SJohn.Forte@Sun.COM if (!rc) {
1115*7836SJohn.Forte@Sun.COM return (NULL);
1116*7836SJohn.Forte@Sun.COM }
1117*7836SJohn.Forte@Sun.COM rcp = rc;
1118*7836SJohn.Forte@Sun.COM
1119*7836SJohn.Forte@Sun.COM while (rdcp) {
1120*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1121*7836SJohn.Forte@Sun.COM /* just in case */
1122*7836SJohn.Forte@Sun.COM strncpy(rdcp->group, group, NSC_MAXPATH);
1123*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
1124*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1125*7836SJohn.Forte@Sun.COM rdccfg.options |= set_mode(rdcp);
1126*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1127*7836SJohn.Forte@Sun.COM
1128*7836SJohn.Forte@Sun.COM /* reconfig group rules enforced in kernel */
1129*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
1130*7836SJohn.Forte@Sun.COM
1131*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
1132*7836SJohn.Forte@Sun.COM if (!rdcp)
1133*7836SJohn.Forte@Sun.COM break;
1134*7836SJohn.Forte@Sun.COM
1135*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
1136*7836SJohn.Forte@Sun.COM rcp = rcp->next;
1137*7836SJohn.Forte@Sun.COM if (!rcp)
1138*7836SJohn.Forte@Sun.COM break;
1139*7836SJohn.Forte@Sun.COM }
1140*7836SJohn.Forte@Sun.COM rcp = rc;
1141*7836SJohn.Forte@Sun.COM rdcp = rdc;
1142*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
1143*7836SJohn.Forte@Sun.COM replace_cfgfield(cfg_rdcs, "group", group);
1144*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
1145*7836SJohn.Forte@Sun.COM
1146*7836SJohn.Forte@Sun.COM return (rc);
1147*7836SJohn.Forte@Sun.COM }
1148*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1149*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_reconfig_ctag(rdcconfig_t * rdc,char * ctag)1150*7836SJohn.Forte@Sun.COM rdc_reconfig_ctag(rdcconfig_t *rdc, char *ctag)
1151*7836SJohn.Forte@Sun.COM {
1152*7836SJohn.Forte@Sun.COM return (NULL);
1153*7836SJohn.Forte@Sun.COM }
1154*7836SJohn.Forte@Sun.COM
1155*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_set_sync(rdcconfig_t * rdc)1156*7836SJohn.Forte@Sun.COM rdc_set_sync(rdcconfig_t *rdc)
1157*7836SJohn.Forte@Sun.COM {
1158*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1159*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
1160*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
1161*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
1162*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
1163*7836SJohn.Forte@Sun.COM
1164*7836SJohn.Forte@Sun.COM rdcp = rdc;
1165*7836SJohn.Forte@Sun.COM rc = new_rc();
1166*7836SJohn.Forte@Sun.COM if (!rc) {
1167*7836SJohn.Forte@Sun.COM return (NULL);
1168*7836SJohn.Forte@Sun.COM }
1169*7836SJohn.Forte@Sun.COM rcp = rc;
1170*7836SJohn.Forte@Sun.COM
1171*7836SJohn.Forte@Sun.COM while (rdcp) {
1172*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1173*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdc);
1174*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1175*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_SYNC;
1176*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1177*7836SJohn.Forte@Sun.COM
1178*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
1179*7836SJohn.Forte@Sun.COM
1180*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
1181*7836SJohn.Forte@Sun.COM if (!rdcp)
1182*7836SJohn.Forte@Sun.COM break;
1183*7836SJohn.Forte@Sun.COM
1184*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
1185*7836SJohn.Forte@Sun.COM rcp = rcp->next;
1186*7836SJohn.Forte@Sun.COM if (!rcp)
1187*7836SJohn.Forte@Sun.COM break;
1188*7836SJohn.Forte@Sun.COM }
1189*7836SJohn.Forte@Sun.COM
1190*7836SJohn.Forte@Sun.COM rcp = rc;
1191*7836SJohn.Forte@Sun.COM rdcp = rdc;
1192*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
1193*7836SJohn.Forte@Sun.COM replace_cfgfield(cfg_rdcs, "mode", "sync");
1194*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
1195*7836SJohn.Forte@Sun.COM
1196*7836SJohn.Forte@Sun.COM return (rc);
1197*7836SJohn.Forte@Sun.COM }
1198*7836SJohn.Forte@Sun.COM
1199*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_set_async(rdcconfig_t * rdc)1200*7836SJohn.Forte@Sun.COM rdc_set_async(rdcconfig_t *rdc)
1201*7836SJohn.Forte@Sun.COM {
1202*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1203*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
1204*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
1205*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
1206*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
1207*7836SJohn.Forte@Sun.COM
1208*7836SJohn.Forte@Sun.COM rdcp = rdc;
1209*7836SJohn.Forte@Sun.COM rc = new_rc();
1210*7836SJohn.Forte@Sun.COM if (!rc) {
1211*7836SJohn.Forte@Sun.COM return (NULL);
1212*7836SJohn.Forte@Sun.COM }
1213*7836SJohn.Forte@Sun.COM rcp = rc;
1214*7836SJohn.Forte@Sun.COM
1215*7836SJohn.Forte@Sun.COM while (rdcp) {
1216*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1217*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
1218*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1219*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_ASYNC;
1220*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1221*7836SJohn.Forte@Sun.COM
1222*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
1223*7836SJohn.Forte@Sun.COM
1224*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
1225*7836SJohn.Forte@Sun.COM if (!rdcp)
1226*7836SJohn.Forte@Sun.COM break;
1227*7836SJohn.Forte@Sun.COM
1228*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
1229*7836SJohn.Forte@Sun.COM rcp = rcp->next;
1230*7836SJohn.Forte@Sun.COM if (!rcp)
1231*7836SJohn.Forte@Sun.COM break;
1232*7836SJohn.Forte@Sun.COM }
1233*7836SJohn.Forte@Sun.COM rcp = rc;
1234*7836SJohn.Forte@Sun.COM rdcp = rdc;
1235*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
1236*7836SJohn.Forte@Sun.COM replace_cfgfield(cfg_rdcs, "mode", "async");
1237*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
1238*7836SJohn.Forte@Sun.COM
1239*7836SJohn.Forte@Sun.COM return (rc);
1240*7836SJohn.Forte@Sun.COM }
1241*7836SJohn.Forte@Sun.COM
1242*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_health(rdcconfig_t * rdc)1243*7836SJohn.Forte@Sun.COM rdc_health(rdcconfig_t *rdc)
1244*7836SJohn.Forte@Sun.COM {
1245*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1246*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
1247*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
1248*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
1249*7836SJohn.Forte@Sun.COM
1250*7836SJohn.Forte@Sun.COM rdcp = rdc;
1251*7836SJohn.Forte@Sun.COM rc = new_rc();
1252*7836SJohn.Forte@Sun.COM if (!rc) {
1253*7836SJohn.Forte@Sun.COM return (NULL);
1254*7836SJohn.Forte@Sun.COM }
1255*7836SJohn.Forte@Sun.COM rcp = rc;
1256*7836SJohn.Forte@Sun.COM
1257*7836SJohn.Forte@Sun.COM while (rdcp) {
1258*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1259*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
1260*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_HEALTH;
1261*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1262*7836SJohn.Forte@Sun.COM
1263*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
1264*7836SJohn.Forte@Sun.COM
1265*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
1266*7836SJohn.Forte@Sun.COM if (!rdcp)
1267*7836SJohn.Forte@Sun.COM break;
1268*7836SJohn.Forte@Sun.COM
1269*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
1270*7836SJohn.Forte@Sun.COM rcp = rcp->next;
1271*7836SJohn.Forte@Sun.COM
1272*7836SJohn.Forte@Sun.COM if (!rcp)
1273*7836SJohn.Forte@Sun.COM break;
1274*7836SJohn.Forte@Sun.COM
1275*7836SJohn.Forte@Sun.COM }
1276*7836SJohn.Forte@Sun.COM return (rc);
1277*7836SJohn.Forte@Sun.COM }
1278*7836SJohn.Forte@Sun.COM
1279*7836SJohn.Forte@Sun.COM rdc_rc_t *
rdc_reverse_role(rdcconfig_t * rdc)1280*7836SJohn.Forte@Sun.COM rdc_reverse_role(rdcconfig_t *rdc)
1281*7836SJohn.Forte@Sun.COM {
1282*7836SJohn.Forte@Sun.COM rdc_config_t rdccfg;
1283*7836SJohn.Forte@Sun.COM rdcconfig_t *rdcp = NULL;
1284*7836SJohn.Forte@Sun.COM rdcconfig_t *cfg_rdcs = NULL;
1285*7836SJohn.Forte@Sun.COM rdc_rc_t *rc = NULL;
1286*7836SJohn.Forte@Sun.COM rdc_rc_t *rcp = NULL;
1287*7836SJohn.Forte@Sun.COM
1288*7836SJohn.Forte@Sun.COM rdcp = rdc;
1289*7836SJohn.Forte@Sun.COM rc = new_rc();
1290*7836SJohn.Forte@Sun.COM if (!rc) {
1291*7836SJohn.Forte@Sun.COM return (NULL);
1292*7836SJohn.Forte@Sun.COM }
1293*7836SJohn.Forte@Sun.COM rcp = rc;
1294*7836SJohn.Forte@Sun.COM
1295*7836SJohn.Forte@Sun.COM while (rdcp) {
1296*7836SJohn.Forte@Sun.COM bzero(&rdccfg, sizeof (rdc_config_t));
1297*7836SJohn.Forte@Sun.COM rdccfg.rdc_set[0] = config2set(rdcp);
1298*7836SJohn.Forte@Sun.COM rdccfg.command = RDC_CMD_RECONFIG;
1299*7836SJohn.Forte@Sun.COM rdccfg.options |= RDC_OPT_REVERSE_ROLE;
1300*7836SJohn.Forte@Sun.COM rdccfg.options |= set_mode(rdcp);
1301*7836SJohn.Forte@Sun.COM populate_addrs(&rdccfg.rdc_set[0], 0);
1302*7836SJohn.Forte@Sun.COM
1303*7836SJohn.Forte@Sun.COM *rcp = rdc_config(&rdccfg);
1304*7836SJohn.Forte@Sun.COM
1305*7836SJohn.Forte@Sun.COM rdcp = rdcp->next;
1306*7836SJohn.Forte@Sun.COM if (!rdcp)
1307*7836SJohn.Forte@Sun.COM break;
1308*7836SJohn.Forte@Sun.COM
1309*7836SJohn.Forte@Sun.COM rcp->next = new_rc();
1310*7836SJohn.Forte@Sun.COM rcp = rcp->next;
1311*7836SJohn.Forte@Sun.COM if (!rcp)
1312*7836SJohn.Forte@Sun.COM break;
1313*7836SJohn.Forte@Sun.COM }
1314*7836SJohn.Forte@Sun.COM rcp = rc;
1315*7836SJohn.Forte@Sun.COM rdcp = rdc;
1316*7836SJohn.Forte@Sun.COM cfg_rdcs = chain_successful(rdcp, rcp);
1317*7836SJohn.Forte@Sun.COM reverse_in_cfg(cfg_rdcs);
1318*7836SJohn.Forte@Sun.COM rdc_free_config(cfg_rdcs, RDC_FREEALL);
1319*7836SJohn.Forte@Sun.COM
1320*7836SJohn.Forte@Sun.COM return (rc);
1321*7836SJohn.Forte@Sun.COM }
1322