Print this page
usr/src/cmd/dlmgmtd/dlmgmt_door.c

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dlmgmtd/dlmgmt_util.c
          +++ new/usr/src/cmd/dlmgmtd/dlmgmt_util.c
↓ open down ↓ 347 lines elided ↑ open up ↑
 348  348  
 349  349  void
 350  350  link_destroy(dlmgmt_link_t *linkp)
 351  351  {
 352  352          linkattr_destroy(linkp);
 353  353          free(linkp);
 354  354  }
 355  355  
 356  356  /*
 357  357   * Set the DLMGMT_ACTIVE flag on the link to note that it is active.
 358      - * When a link is active and is owned by an NGZ then it is added to
      358 + * When a link is active and owned by an NGZ then it is added to
 359  359   * that zone's datalink list.
 360  360   */
 361  361  int
 362  362  link_activate(dlmgmt_link_t *linkp)
 363  363  {
 364  364          int             err = 0;
 365  365          zoneid_t        zoneid = ALL_ZONES;
 366  366  
 367  367          /*
 368  368           * If zone_check_datalink() returns 0 it means we found the
↓ open down ↓ 8 lines elided ↑ open up ↑
 377  377                   * the GZ. This means that the link is supposed to be
 378  378                   * loaned out to an NGZ but the dlmgmtd state is out
 379  379                   * of sync -- possibly due to the process restarting.
 380  380                   * In this case we need to sync the dlmgmtd state by
 381  381                   * marking it as on-loan to the NGZ it's currently
 382  382                   * under.
 383  383                   */
 384  384                  if (zoneid != linkp->ll_zoneid) {
 385  385                          assert(linkp->ll_zoneid == 0);
 386  386                          assert(linkp->ll_onloan == B_FALSE);
      387 +                        assert(linkp->ll_transient == 0);
 387  388  
 388  389                          /*
 389  390                           * If dlmgmtd already has a link with this
 390  391                           * name under the NGZ then we have a problem.
 391  392                           */
 392  393                          if (link_by_name(linkp->ll_link, zoneid) != NULL) {
 393  394                                  err = EEXIST;
 394  395                                  goto done;
 395  396                          }
 396  397  
↓ open down ↓ 18 lines elided ↑ open up ↑
 415  416  
 416  417                          /*
 417  418                           * When a VNIC is not persistent and loaned to
 418  419                           * a zone it is considered transient. This is
 419  420                           * the same logic found in do_create_vnic()
 420  421                           * and is needed here in the event of a
 421  422                           * dlmgmtd restart.
 422  423                           */
 423  424                          if (linkp->ll_class == DATALINK_CLASS_VNIC &&
 424  425                              !(linkp->ll_flags & DLMGMT_PERSIST))
 425      -                                linkp->ll_trans = B_TRUE;
      426 +                                linkp->ll_transient = B_TRUE;
 426  427                  }
 427  428          } else if (linkp->ll_zoneid != GLOBAL_ZONEID) {
 428  429                  /*
 429      -                 * In this case the link was not found under any NGZs
      430 +                 * In this case the link was not found under any NGZ
 430  431                   * but according to its ll_zoneid member it is owned
 431  432                   * by an NGZ. Add the datalink to the appropriate zone
 432  433                   * datalink list.
 433  434                   */
 434  435                  err = zone_add_datalink(linkp->ll_zoneid, linkp->ll_linkid);
 435  436                  assert(linkp->ll_onloan == B_FALSE);
 436  437          }
 437  438  done:
 438  439          if (err == 0)
 439  440                  linkp->ll_flags |= DLMGMT_ACTIVE;
↓ open down ↓ 43 lines elided ↑ open up ↑
 483  484          dlmgmt_link_t   *linkp = NULL;
 484  485          avl_index_t     name_where, id_where;
 485  486          int             err = 0;
 486  487  
 487  488          if (!dladm_valid_linkname(name))
 488  489                  return (EINVAL);
 489  490          if (dlmgmt_nextlinkid == DATALINK_INVALID_LINKID)
 490  491                  return (ENOSPC);
 491  492          if (flags & ~(DLMGMT_ACTIVE | DLMGMT_PERSIST | DLMGMT_TRANSIENT) ||
 492  493              ((flags & DLMGMT_PERSIST) && (flags & DLMGMT_TRANSIENT)) ||
 493      -            flags == 0)
      494 +            flags == 0) {
 494  495                  return (EINVAL);
      496 +        }
 495  497  
 496  498          if ((linkp = calloc(1, sizeof (dlmgmt_link_t))) == NULL) {
 497  499                  err = ENOMEM;
 498  500                  goto done;
 499  501          }
 500  502  
 501  503          (void) strlcpy(linkp->ll_link, name, MAXLINKNAMELEN);
 502  504          linkp->ll_class = class;
 503  505          linkp->ll_media = media;
 504  506          linkp->ll_linkid = dlmgmt_nextlinkid;
 505  507          linkp->ll_zoneid = zoneid;
 506  508          linkp->ll_gen = 0;
 507  509  
 508  510          /*
 509  511           * While DLMGMT_TRANSIENT starts off as a flag it is converted
 510  512           * into a link field since it is really a substate of
 511  513           * DLMGMT_ACTIVE -- it should not survive as a flag beyond
 512  514           * this point.
 513  515           */
 514      -        linkp->ll_trans = (flags & DLMGMT_TRANSIENT) ? B_TRUE : B_FALSE;
      516 +        linkp->ll_transient = (flags & DLMGMT_TRANSIENT) ? B_TRUE : B_FALSE;
 515  517          flags &= ~DLMGMT_TRANSIENT;
 516  518  
 517  519          if (avl_find(&dlmgmt_name_avl, linkp, &name_where) != NULL ||
 518  520              avl_find(&dlmgmt_id_avl, linkp, &id_where) != NULL) {
 519  521                  err = EEXIST;
 520  522                  goto done;
 521  523          }
 522  524  
 523  525          avl_insert(&dlmgmt_name_avl, linkp, name_where);
 524  526          avl_insert(&dlmgmt_id_avl, linkp, id_where);
↓ open down ↓ 327 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX