Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c
+++ new/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 24 * Copyright 2015 Joyent, Inc.
25 25 */
26 26
27 27 /*
28 28 * The ipmgmtd daemon is started by ip-interface-management SMF service. This
29 29 * daemon is used to manage, mapping of 'address object' to 'interface name' and
30 30 * 'logical interface number', on which the address is created. It also provides
31 31 * a means to update the ipadm persistent data-store.
32 32 *
33 33 * The daemon tracks the <addrobj, lifname> mapping in-memory using a linked
34 34 * list `aobjmap'. Access to this list is synchronized using a readers-writers
35 35 * lock. The active <addrobj, lifname> mapping is kept in
36 36 * /etc/svc/volatile/ipadm/aobjmap.conf cache file, so that the mapping can be
37 37 * recovered when ipmgmtd exits for some reason (e.g., when ipmgmtd is restarted
38 38 * using svcadm or accidentally killed).
39 39 *
40 40 * Today, the persistent configuration of interfaces, addresses and protocol
41 41 * properties is kept in /etc/ipadm/ipadm.conf. The access to the persistent
42 42 * data store is synchronized using reader-writers lock `ipmgmt_dbconf_lock'.
43 43 *
44 44 * The communication between the library, libipadm.so and the daemon, is through
45 45 * doors RPC. The library interacts with the daemon using the commands defined
46 46 * by `ipmgmt_door_cmd_type_t'. Further any 'write' operation would require
47 47 * the `NETWORK_INTERFACE_CONFIG_AUTH' authorization.
48 48 *
49 49 * On reboot, the aforementioned SMF service starts the daemon before any other
50 50 * networking service that configures network IP interfaces is started.
51 51 * Afterwards, the network/physical SMF script instantiates the persisted
52 52 * network interfaces, interface properties and addresses.
53 53 */
54 54
55 55 #include <errno.h>
56 56 #include <fcntl.h>
57 57 #include <priv_utils.h>
58 58 #include <signal.h>
59 59 #include <stdlib.h>
60 60 #include <stdio.h>
61 61 #include <strings.h>
62 62 #include <sys/param.h>
63 63 #include <sys/stat.h>
64 64 #include <unistd.h>
65 65 #include "ipmgmt_impl.h"
66 66 #include <zone.h>
67 67 #include <libipadm.h>
68 68 #include <libdladm.h>
69 69 #include <libdllink.h>
70 70 #include <net/route.h>
71 71 #include <ipadm_ipmgmt.h>
72 72 #include <sys/brand.h>
73 73
74 74 const char *progname;
75 75
76 76 /* readers-writers lock for reading/writing daemon data store */
77 77 pthread_rwlock_t ipmgmt_dbconf_lock = PTHREAD_RWLOCK_INITIALIZER;
78 78
79 79 /* tracks address object to {ifname|logical number|interface id} mapping */
80 80 ipmgmt_aobjmap_list_t aobjmap;
81 81
82 82 /* used to communicate failure to parent process, which spawned the daemon */
83 83 static int pfds[2];
84 84
85 85 /* file descriptor to IPMGMT_DOOR */
86 86 static int ipmgmt_door_fd = -1;
87 87
88 88 static void ipmgmt_exit(int);
89 89 static int ipmgmt_init();
90 90 static int ipmgmt_init_privileges();
91 91 static void ipmgmt_ngz_persist_if();
92 92
93 93 static ipadm_handle_t iph;
94 94 typedef struct ipmgmt_pif_s {
95 95 struct ipmgmt_pif_s *pif_next;
96 96 char pif_ifname[LIFNAMSIZ];
97 97 boolean_t pif_v4;
98 98 boolean_t pif_v6;
99 99 } ipmgmt_pif_t;
100 100
101 101 static ipmgmt_pif_t *ngz_pifs;
102 102
103 103 static int
104 104 ipmgmt_db_init()
105 105 {
106 106 int fd, err, scferr;
107 107 scf_resources_t res;
108 108 boolean_t upgrade = B_TRUE;
109 109 char aobjpath[MAXPATHLEN];
110 110
111 111 /*
112 112 * Check to see if we need to upgrade the data-store. We need to
113 113 * upgrade, if the version of the data-store does not match with
114 114 * IPADM_DB_VERSION. Further, if we cannot determine the current
115 115 * version of the data-store, we always err on the side of caution
116 116 * and upgrade the data-store to current version.
117 117 */
118 118 if ((scferr = ipmgmt_create_scf_resources(IPMGMTD_FMRI, &res)) == 0)
119 119 upgrade = ipmgmt_needs_upgrade(&res);
120 120 if (upgrade) {
121 121 err = ipmgmt_db_walk(ipmgmt_db_upgrade, NULL, IPADM_DB_WRITE);
122 122 if (err != 0) {
123 123 ipmgmt_log(LOG_ERR, "could not upgrade the "
124 124 "ipadm data-store: %s", strerror(err));
125 125 err = 0;
126 126 } else {
127 127 /*
128 128 * upgrade was success, let's update SCF with the
129 129 * current data-store version number.
130 130 */
131 131 if (scferr == 0)
132 132 ipmgmt_update_dbver(&res);
133 133 }
134 134 }
135 135 if (scferr == 0)
136 136 ipmgmt_release_scf_resources(&res);
137 137
138 138 /* creates the address object data store, if it doesn't exist */
139 139 ipmgmt_path(IPADM_PATH_ADDROBJ_MAP_DB, aobjpath, sizeof (aobjpath));
140 140 if ((fd = open(aobjpath, O_CREAT|O_RDONLY, IPADM_FILE_MODE)) == -1) {
141 141 err = errno;
142 142 ipmgmt_log(LOG_ERR, "could not open %s: %s", aobjpath,
143 143 strerror(err));
144 144 return (err);
145 145 }
146 146 (void) close(fd);
147 147
148 148 aobjmap.aobjmap_head = NULL;
149 149 (void) pthread_rwlock_init(&aobjmap.aobjmap_rwlock, NULL);
150 150
151 151 /*
152 152 * If the daemon is recovering from a crash or restart, read the
153 153 * address object to logical interface mapping and build an in-memory
154 154 * representation of the mapping. That is, build `aobjmap' structure
155 155 * from address object data store.
156 156 */
157 157 if ((err = ipadm_rw_db(ipmgmt_aobjmap_init, NULL, aobjpath, 0,
158 158 IPADM_DB_READ)) != 0) {
159 159 /* if there was nothing to initialize, it's fine */
160 160 if (err != ENOENT)
161 161 return (err);
162 162 err = 0;
163 163 }
164 164
165 165 ipmgmt_ngz_persist_if(); /* create persistent interface info for NGZ */
166 166
167 167 return (err);
168 168 }
169 169
170 170 static const char *
171 171 ipmgmt_door_path()
172 172 {
173 173 static char door[MAXPATHLEN];
174 174 static boolean_t init_done = B_FALSE;
175 175
176 176 if (!init_done) {
177 177 const char *zroot = zone_get_nroot();
178 178
179 179 /*
180 180 * If this is a branded zone, make sure we use the "/native"
181 181 * prefix for the door path:
182 182 */
183 183 (void) snprintf(door, sizeof (door), "%s%s", zroot != NULL ?
184 184 zroot : "", IPMGMT_DOOR);
185 185
186 186 init_done = B_TRUE;
187 187 }
188 188
189 189 return (door);
190 190 }
191 191
192 192 static int
193 193 ipmgmt_door_init()
194 194 {
195 195 int fd;
196 196 int err;
197 197 const char *door = ipmgmt_door_path();
198 198
199 199 /*
200 200 * Create the door file for ipmgmtd.
201 201 */
202 202 if ((fd = open(door, O_CREAT | O_RDONLY, IPADM_FILE_MODE)) == -1) {
203 203 err = errno;
204 204 ipmgmt_log(LOG_ERR, "could not open %s: %s", door,
205 205 strerror(err));
206 206 return (err);
207 207 }
208 208 (void) close(fd);
209 209
210 210 if ((ipmgmt_door_fd = door_create(ipmgmt_handler, NULL,
211 211 DOOR_REFUSE_DESC | DOOR_NO_CANCEL)) == -1) {
212 212 err = errno;
213 213 ipmgmt_log(LOG_ERR, "failed to create door: %s", strerror(err));
214 214 return (err);
215 215 }
216 216
217 217 /*
218 218 * fdetach first in case a previous daemon instance exited
219 219 * ungracefully.
220 220 */
221 221 (void) fdetach(door);
222 222 if (fattach(ipmgmt_door_fd, door) != 0) {
223 223 err = errno;
224 224 ipmgmt_log(LOG_ERR, "failed to attach door to %s: %s", door,
225 225 strerror(err));
226 226 goto fail;
227 227 }
228 228 return (0);
229 229 fail:
230 230 (void) door_revoke(ipmgmt_door_fd);
231 231 ipmgmt_door_fd = -1;
232 232 return (err);
233 233 }
234 234
235 235 static void
236 236 ipmgmt_door_fini()
237 237 {
238 238 const char *door = ipmgmt_door_path();
239 239
240 240 if (ipmgmt_door_fd == -1)
241 241 return;
242 242
243 243 (void) fdetach(door);
244 244 if (door_revoke(ipmgmt_door_fd) == -1) {
245 245 ipmgmt_log(LOG_ERR, "failed to revoke access to door %s: %s",
246 246 door, strerror(errno));
247 247 }
248 248 }
249 249
250 250 static int
251 251 ipmgmt_init()
252 252 {
253 253 int err;
254 254
255 255 if (signal(SIGTERM, ipmgmt_exit) == SIG_ERR ||
256 256 signal(SIGINT, ipmgmt_exit) == SIG_ERR) {
257 257 err = errno;
258 258 ipmgmt_log(LOG_ERR, "signal() for SIGTERM/INT failed: %s",
259 259 strerror(err));
260 260 return (err);
261 261 }
262 262 if ((err = ipmgmt_db_init()) != 0 || (err = ipmgmt_door_init()) != 0)
263 263 return (err);
264 264 return (0);
265 265 }
266 266
267 267 /*
268 268 * This is called by the child process to inform the parent process to
269 269 * exit with the given return value.
270 270 */
271 271 static void
272 272 ipmgmt_inform_parent_exit(int rv)
273 273 {
274 274 if (write(pfds[1], &rv, sizeof (int)) != sizeof (int)) {
275 275 ipmgmt_log(LOG_WARNING,
276 276 "failed to inform parent process of status: %s",
277 277 strerror(errno));
278 278 (void) close(pfds[1]);
279 279 exit(EXIT_FAILURE);
280 280 }
281 281 (void) close(pfds[1]);
282 282 }
283 283
284 284 /*ARGSUSED*/
285 285 static void
286 286 ipmgmt_exit(int signo)
287 287 {
288 288 (void) close(pfds[1]);
289 289 ipmgmt_door_fini();
290 290 exit(EXIT_FAILURE);
291 291 }
292 292
293 293 /*
294 294 * On the first reboot after installation of an ipkg zone,
295 295 * ipmgmt_persist_if_cb() is used in non-global zones to track the interfaces
296 296 * that have IP address configuration assignments from the global zone.
297 297 * Persistent configuration for the interfaces is created on the first boot
298 298 * by ipmgmtd, and the addresses assigned to the interfaces by the GZ
299 299 * will be subsequently configured when the interface is enabled.
300 300 * Note that ipmgmt_persist_if_cb() only sets up a list of interfaces
301 301 * that need to be persisted- the actual update of the ipadm data-store happens
302 302 * in ipmgmt_persist_if() after the appropriate privs/uid state has been set up.
303 303 */
304 304 static void
305 305 ipmgmt_persist_if_cb(char *ifname, boolean_t v4, boolean_t v6)
306 306 {
307 307 ipmgmt_pif_t *pif;
308 308
309 309 pif = calloc(1, sizeof (*pif));
310 310 if (pif == NULL) {
311 311 ipmgmt_log(LOG_WARNING,
312 312 "Could not allocate memory to configure %s", ifname);
313 313 return;
314 314 }
315 315 (void) strlcpy(pif->pif_ifname, ifname, sizeof (pif->pif_ifname));
316 316 pif->pif_v4 = v4;
317 317 pif->pif_v6 = v6;
318 318 pif->pif_next = ngz_pifs;
319 319 ngz_pifs = pif;
320 320 }
321 321
322 322 /*
323 323 * ipmgmt_ngz_init() initializes exclusive-IP stack non-global zones by
324 324 * extracting configuration that has been saved in the kernel and applying
325 325 * it at zone boot.
326 326 */
327 327 static void
328 328 ipmgmt_ngz_init()
329 329 {
330 330 zoneid_t zoneid;
331 331 boolean_t firstboot = B_TRUE, s10c = B_FALSE;
332 332 char brand[MAXNAMELEN];
333 333 ipadm_status_t ipstatus;
334 334
335 335 zoneid = getzoneid();
336 336 if (zoneid != GLOBAL_ZONEID) {
337 337
338 338 if (zone_getattr(zoneid, ZONE_ATTR_BRAND, brand,
339 339 sizeof (brand)) < 0) {
340 340 ipmgmt_log(LOG_ERR, "Could not get brand name");
341 341 return;
342 342 }
343 343 /*
344 344 * firstboot is always true for S10C zones, where ipadm is not
345 345 * available for restoring persistent configuration.
346 346 */
347 347 if (strcmp(brand, NATIVE_BRAND_NAME) == 0)
348 348 firstboot = ipmgmt_ngz_firstboot_postinstall();
349 349 else
350 350 s10c = B_TRUE;
351 351
352 352 if (!firstboot)
353 353 return;
354 354
355 355 ipstatus = ipadm_open(&iph, IPH_IPMGMTD);
356 356 if (ipstatus != IPADM_SUCCESS) {
357 357 ipmgmt_log(LOG_ERR, "could not open ipadm handle",
358 358 ipadm_status2str(ipstatus));
359 359 return;
360 360 }
361 361 /*
362 362 * Only pass down the callback to persist the interface
363 363 * for NATIVE (ipkg) zones.
364 364 */
365 365 (void) ipadm_init_net_from_gz(iph, NULL,
366 366 (s10c ? NULL : ipmgmt_persist_if_cb));
367 367 ipadm_close(iph);
368 368 }
369 369 }
370 370
371 371 /*
372 372 * Set the uid of this daemon to the "netadm" user. Finish the following
373 373 * operations before setuid() because they need root privileges:
374 374 *
375 375 * - create the /etc/svc/volatile/ipadm directory;
376 376 * - change its uid/gid to "netadm"/"netadm";
377 377 */
378 378 static int
379 379 ipmgmt_init_privileges()
380 380 {
381 381 struct stat statbuf;
382 382 int err;
383 383 char tmpfsdir[MAXPATHLEN];
384 384
385 385 /*
386 386 * Create the volatile storage directory:
387 387 */
388 388 ipmgmt_path(IPADM_PATH_TMPFS_DIR, tmpfsdir, sizeof (tmpfsdir));
389 389 if (stat(tmpfsdir, &statbuf) < 0) {
390 390 if (mkdir(tmpfsdir, (mode_t)0755) < 0) {
391 391 err = errno;
392 392 goto fail;
393 393 }
394 394 } else {
395 395 if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
396 396 err = ENOTDIR;
397 397 goto fail;
398 398 }
399 399 }
400 400
401 401 if ((chmod(tmpfsdir, 0755) < 0) ||
402 402 (chown(tmpfsdir, UID_NETADM, GID_NETADM) < 0)) {
403 403 err = errno;
404 404 goto fail;
405 405 }
406 406
407 407 /*
408 408 * initialize any NGZ specific network information before dropping
409 409 * privileges. We need these privileges to plumb IP interfaces handed
410 410 * down from the GZ (for dlpi_open() etc.) and also to configure the
411 411 * address itself (for any IPI_PRIV ioctls like SLIFADDR)
412 412 */
413 413 ipmgmt_ngz_init();
414 414
415 415 /*
416 416 * Apply all protocol module properties. We need to apply all protocol
417 417 * properties before we drop root privileges.
418 418 */
419 419 ipmgmt_init_prop();
420 420
421 421 /*
422 422 * limit the privileges of this daemon and set the uid of this
423 423 * daemon to UID_NETADM
424 424 */
425 425 if (__init_daemon_priv(PU_RESETGROUPS|PU_CLEARLIMITSET, UID_NETADM,
426 426 GID_NETADM, NULL) == -1) {
427 427 err = EPERM;
428 428 goto fail;
429 429 }
430 430
431 431 return (0);
432 432 fail:
433 433 (void) ipmgmt_log(LOG_ERR, "failed to initialize the daemon: %s",
434 434 strerror(err));
435 435 return (err);
436 436 }
437 437
438 438 /*
439 439 * Keep the pfds fd open, close other fds.
440 440 */
441 441 /*ARGSUSED*/
442 442 static int
443 443 closefunc(void *arg, int fd)
444 444 {
445 445 if (fd != pfds[1])
446 446 (void) close(fd);
447 447 return (0);
448 448 }
449 449
450 450 /*
451 451 * We cannot use libc's daemon() because the door we create is associated with
452 452 * the process ID. If we create the door before the call to daemon(), it will
453 453 * be associated with the parent and it's incorrect. On the other hand if we
454 454 * create the door later, after the call to daemon(), parent process exits
455 455 * early and gives a false notion to SMF that 'ipmgmtd' is up and running,
456 456 * which is incorrect. So, we have our own daemon() equivalent.
457 457 */
458 458 static boolean_t
459 459 ipmgmt_daemonize(void)
460 460 {
461 461 pid_t pid;
462 462 int rv;
463 463
464 464 if (pipe(pfds) < 0) {
465 465 (void) fprintf(stderr, "%s: pipe() failed: %s\n",
466 466 progname, strerror(errno));
467 467 exit(EXIT_FAILURE);
468 468 }
469 469
470 470 if ((pid = fork()) == -1) {
471 471 (void) fprintf(stderr, "%s: fork() failed: %s\n",
472 472 progname, strerror(errno));
473 473 exit(EXIT_FAILURE);
474 474 } else if (pid > 0) { /* Parent */
475 475 (void) close(pfds[1]);
476 476
477 477 /*
478 478 * Parent should not exit early, it should wait for the child
479 479 * to return Success/Failure. If the parent exits early, then
480 480 * SMF will think 'ipmgmtd' is up and would start all the
481 481 * depended services.
482 482 *
483 483 * If the child process exits unexpectedly, read() returns -1.
484 484 */
485 485 if (read(pfds[0], &rv, sizeof (int)) != sizeof (int)) {
486 486 (void) kill(pid, SIGKILL);
487 487 rv = EXIT_FAILURE;
488 488 }
489 489
490 490 (void) close(pfds[0]);
491 491 exit(rv);
492 492 }
493 493
494 494 /* Child */
495 495 (void) close(pfds[0]);
496 496 (void) setsid();
497 497
498 498 /* close all files except pfds[1] */
499 499 (void) fdwalk(closefunc, NULL);
500 500 (void) chdir("/");
501 501 openlog(progname, LOG_PID, LOG_DAEMON);
502 502 return (B_TRUE);
503 503 }
504 504
505 505 int
506 506 main(int argc, char *argv[])
507 507 {
508 508 int opt;
509 509 boolean_t fg = B_FALSE;
510 510
511 511 progname = strrchr(argv[0], '/');
512 512 if (progname != NULL)
513 513 progname++;
514 514 else
515 515 progname = argv[0];
516 516
517 517 /* Process options */
518 518 while ((opt = getopt(argc, argv, "f")) != EOF) {
519 519 switch (opt) {
520 520 case 'f':
521 521 fg = B_TRUE;
522 522 break;
523 523 default:
524 524 (void) fprintf(stderr, "Usage: %s [-f]\n", progname);
525 525 return (EXIT_FAILURE);
526 526 }
527 527 }
528 528
529 529 if (!fg && getenv("SMF_FMRI") == NULL) {
530 530 (void) fprintf(stderr,
531 531 "ipmgmtd is a smf(5) managed service and cannot be run "
532 532 "from the command line.\n");
533 533 return (EINVAL);
534 534 }
535 535
536 536 if (!fg && !ipmgmt_daemonize())
537 537 return (EXIT_FAILURE);
538 538
539 539 if (ipmgmt_init_privileges() != 0)
540 540 goto child_out;
541 541
542 542 if (ipmgmt_init() != 0)
543 543 goto child_out;
544 544
545 545 /* Inform the parent process that it can successfully exit */
546 546 ipmgmt_inform_parent_exit(EXIT_SUCCESS);
547 547
548 548 for (;;)
549 549 (void) pause();
550 550
551 551 child_out:
552 552 /* return from main() forcibly exits an MT process */
553 553 ipmgmt_inform_parent_exit(EXIT_FAILURE);
554 554 return (EXIT_FAILURE);
555 555 }
556 556
557 557 /*
558 558 * Return TRUE if `ifname' has persistent configuration for the `af' address
559 559 * family in the datastore
560 560 */
561 561 static boolean_t
562 562 ipmgmt_persist_if_exists(char *ifname, sa_family_t af)
563 563 {
564 564 ipmgmt_getif_cbarg_t cbarg;
565 565 boolean_t exists = B_FALSE;
566 566 ipadm_if_info_t *ifp;
567 567
568 568 bzero(&cbarg, sizeof (cbarg));
569 569 cbarg.cb_ifname = ifname;
570 570 (void) ipmgmt_db_walk(ipmgmt_db_getif, &cbarg, IPADM_DB_READ);
571 571 if ((ifp = cbarg.cb_ifinfo) != NULL) {
572 572 if ((af == AF_INET && (ifp->ifi_pflags & IFIF_IPV4)) ||
573 573 (af == AF_INET6 && (ifp->ifi_pflags & IFIF_IPV6))) {
574 574 exists = B_TRUE;
575 575 }
576 576 }
577 577 free(ifp);
578 578 return (exists);
579 579 }
580 580
581 581 /*
582 582 * Persist any NGZ interfaces assigned to us from the global zone if they do
583 583 * not already exist in the persistent db. We need to
584 584 * do this before any calls to ipadm_enable_if() can succeed (i.e.,
585 585 * before opening up for door_calls), and after setuid to 'netadm' so that
586 586 * the persistent db is created with the right permissions.
587 587 */
588 588 static void
589 589 ipmgmt_ngz_persist_if()
590 590 {
591 591 ipmgmt_pif_t *pif, *next;
592 592 ipmgmt_if_arg_t ifarg;
593 593
594 594 for (pif = ngz_pifs; pif != NULL; pif = next) {
595 595 next = pif->pif_next;
596 596 bzero(&ifarg, sizeof (ifarg));
597 597 (void) strlcpy(ifarg.ia_ifname, pif->pif_ifname,
598 598 sizeof (ifarg.ia_ifname));
599 599 ifarg.ia_flags = IPMGMT_PERSIST;
600 600 if (pif->pif_v4 &&
601 601 !ipmgmt_persist_if_exists(pif->pif_ifname, AF_INET)) {
602 602 ifarg.ia_family = AF_INET;
603 603 (void) ipmgmt_persist_if(&ifarg);
604 604 }
605 605 if (pif->pif_v6 &&
606 606 !ipmgmt_persist_if_exists(pif->pif_ifname, AF_INET6)) {
607 607 ifarg.ia_family = AF_INET6;
608 608 (void) ipmgmt_persist_if(&ifarg);
609 609 }
610 610 free(pif);
611 611 }
612 612 ngz_pifs = NULL; /* no red herrings */
613 613 }
|
↓ open down ↓ |
613 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX