Print this page
Commit IPMP changes


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 /*
  27  * The ipmgmtd daemon is started by ip-interface-management SMF service. This
  28  * daemon is used to manage, mapping of 'address object' to 'interface name' and
  29  * 'logical interface number', on which the address is created. It also provides
  30  * a means to update the ipadm persistent data-store.
  31  *
  32  * The daemon tracks the <addrobj, lifname> mapping in-memory using a linked
  33  * list `aobjmap'. Access to this list is synchronized using a readers-writers
  34  * lock. The active <addrobj, lifname> mapping is kept in
  35  * /etc/svc/volatile/ipadm/aobjmap.conf cache file, so that the mapping can be
  36  * recovered when ipmgmtd exits for some reason (e.g., when ipmgmtd is restarted
  37  * using svcadm or accidentally killed).
  38  *
  39  * Today, the persistent configuration of interfaces, addresses and protocol
  40  * properties is kept in /etc/ipadm/ipadm.conf. The access to the persistent
  41  * data store is synchronized using reader-writers lock `ipmgmt_dbconf_lock'.
  42  *
  43  * The communication between the library, libipadm.so and the daemon, is through


 503                 return (EXIT_FAILURE);
 504 
 505         if (ipmgmt_init_privileges() != 0)
 506                 goto child_out;
 507 
 508         if (ipmgmt_init() != 0)
 509                 goto child_out;
 510 
 511         /* Inform the parent process that it can successfully exit */
 512         ipmgmt_inform_parent_exit(EXIT_SUCCESS);
 513 
 514         for (;;)
 515                 (void) pause();
 516 
 517 child_out:
 518         /* return from main() forcibly exits an MT process */
 519         ipmgmt_inform_parent_exit(EXIT_FAILURE);
 520         return (EXIT_FAILURE);
 521 }
 522 
 523 /*
 524  * Return TRUE if `ifname' has persistent configuration for the `af' address
 525  * family in the datastore
 526  */
 527 static boolean_t
 528 ipmgmt_persist_if_exists(char *ifname, sa_family_t af)
 529 {
 530         ipmgmt_getif_cbarg_t cbarg;
 531         boolean_t exists = B_FALSE;
 532         ipadm_if_info_t *ifp;
 533 
 534         bzero(&cbarg, sizeof (cbarg));
 535         cbarg.cb_ifname = ifname;
 536         (void) ipmgmt_db_walk(ipmgmt_db_getif, &cbarg, IPADM_DB_READ);
 537         if ((ifp = cbarg.cb_ifinfo) != NULL) {
 538                 if ((af == AF_INET && (ifp->ifi_pflags & IFIF_IPV4)) ||
 539                     (af == AF_INET6 && (ifp->ifi_pflags & IFIF_IPV6))) {
 540                         exists = B_TRUE;
 541                 }
 542         }
 543         free(ifp);
 544         return (exists);
 545 }
 546 
 547 /*
 548  * Persist any NGZ interfaces assigned to us from the global zone if they do
 549  * not already exist in the persistent db. We need to
 550  * do this before any calls to ipadm_enable_if() can succeed (i.e.,
 551  * before opening up for door_calls), and after setuid to 'netadm' so that
 552  * the persistent db is created with the right permissions.
 553  */
 554 static void
 555 ipmgmt_ngz_persist_if()
 556 {
 557         ipmgmt_pif_t *pif, *next;
 558         ipmgmt_if_arg_t ifarg;
 559 
 560         for (pif = ngz_pifs; pif != NULL; pif = next) {
 561                 next = pif->pif_next;
 562                 bzero(&ifarg, sizeof (ifarg));
 563                 (void) strlcpy(ifarg.ia_ifname, pif->pif_ifname,
 564                     sizeof (ifarg.ia_ifname));
 565                 ifarg.ia_flags = IPMGMT_PERSIST;
 566                 if (pif->pif_v4 &&


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  25  */
  26 
  27 /*
  28  * The ipmgmtd daemon is started by ip-interface-management SMF service. This
  29  * daemon is used to manage, mapping of 'address object' to 'interface name' and
  30  * 'logical interface number', on which the address is created. It also provides
  31  * a means to update the ipadm persistent data-store.
  32  *
  33  * The daemon tracks the <addrobj, lifname> mapping in-memory using a linked
  34  * list `aobjmap'. Access to this list is synchronized using a readers-writers
  35  * lock. The active <addrobj, lifname> mapping is kept in
  36  * /etc/svc/volatile/ipadm/aobjmap.conf cache file, so that the mapping can be
  37  * recovered when ipmgmtd exits for some reason (e.g., when ipmgmtd is restarted
  38  * using svcadm or accidentally killed).
  39  *
  40  * Today, the persistent configuration of interfaces, addresses and protocol
  41  * properties is kept in /etc/ipadm/ipadm.conf. The access to the persistent
  42  * data store is synchronized using reader-writers lock `ipmgmt_dbconf_lock'.
  43  *
  44  * The communication between the library, libipadm.so and the daemon, is through


 504                 return (EXIT_FAILURE);
 505 
 506         if (ipmgmt_init_privileges() != 0)
 507                 goto child_out;
 508 
 509         if (ipmgmt_init() != 0)
 510                 goto child_out;
 511 
 512         /* Inform the parent process that it can successfully exit */
 513         ipmgmt_inform_parent_exit(EXIT_SUCCESS);
 514 
 515         for (;;)
 516                 (void) pause();
 517 
 518 child_out:
 519         /* return from main() forcibly exits an MT process */
 520         ipmgmt_inform_parent_exit(EXIT_FAILURE);
 521         return (EXIT_FAILURE);
 522 }
 523 
























 524 /*
 525  * Persist any NGZ interfaces assigned to us from the global zone if they do
 526  * not already exist in the persistent db. We need to
 527  * do this before any calls to ipadm_enable_if() can succeed (i.e.,
 528  * before opening up for door_calls), and after setuid to 'netadm' so that
 529  * the persistent db is created with the right permissions.
 530  */
 531 static void
 532 ipmgmt_ngz_persist_if()
 533 {
 534         ipmgmt_pif_t *pif, *next;
 535         ipmgmt_if_arg_t ifarg;
 536 
 537         for (pif = ngz_pifs; pif != NULL; pif = next) {
 538                 next = pif->pif_next;
 539                 bzero(&ifarg, sizeof (ifarg));
 540                 (void) strlcpy(ifarg.ia_ifname, pif->pif_ifname,
 541                     sizeof (ifarg.ia_ifname));
 542                 ifarg.ia_flags = IPMGMT_PERSIST;
 543                 if (pif->pif_v4 &&