Print this page
OS-249


   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 #include <stdio.h>
  27 #include <door.h>
  28 #include <errno.h>
  29 #include <strings.h>
  30 #include <sys/mman.h>
  31 #include <libdladm.h>
  32 #include <libdlib.h>
  33 #include <libdllink.h>
  34 
  35 extern dladm_status_t   dladm_door_fd(dladm_handle_t, int *);
  36 
  37 static dladm_status_t
  38 ibd_dladm_door_call(dladm_handle_t handle, void *arg, size_t asize, void *rbuf,
  39     size_t rsize)
  40 {
  41         door_arg_t      darg;
  42         int             door_fd;
  43         dladm_status_t  status = DLADM_STATUS_OK;


  69         if (darg.rsize != rsize)
  70                 return (DLADM_STATUS_FAILED);
  71 
  72         if ((((dlmgmt_retval_t *)rbuf)->lr_err) == 0)
  73                 return (DLADM_STATUS_OK);
  74         else
  75                 return (DLADM_STATUS_FAILED);
  76 }
  77 
  78 static int
  79 ibd_delete_link(dladm_handle_t dlh, char *link)
  80 {
  81         dlmgmt_door_getlinkid_t         getlinkid;
  82         dlmgmt_getlinkid_retval_t       retval;
  83         datalink_id_t                   linkid;
  84         dladm_status_t                  status;
  85         char                            errmsg[DLADM_STRSIZE];
  86 
  87         getlinkid.ld_cmd = DLMGMT_CMD_GETLINKID;
  88         (void) strlcpy(getlinkid.ld_link, link, MAXLINKNAMELEN);

  89 
  90         if ((status = ibd_dladm_door_call(dlh, &getlinkid, sizeof (getlinkid),
  91             &retval, sizeof (retval))) != DLADM_STATUS_OK) {
  92                 (void) fprintf(stderr,
  93                     "dladm_door_call failed: %s; linkname = %s\n",
  94                     dladm_status2str(status, errmsg), link);
  95                 return (status);
  96         }
  97 
  98         if (retval.lr_class != DATALINK_CLASS_PHYS) {
  99                 (void) fprintf(stderr,
 100                     "Not a physical link: linkname = %s, class = 0x%x\n",
 101                     link, (uint_t)retval.lr_class);
 102                 return (status);
 103         }
 104 
 105         linkid = retval.lr_linkid;
 106 
 107         if ((status = dladm_remove_conf(dlh, linkid)) != DLADM_STATUS_OK) {
 108                 (void) fprintf(stderr, "dladm_remove_conf failed: %s\n",




   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 (c) 2011, Joyent Inc. All rights reserved.
  25  */
  26 
  27 #include <stdio.h>
  28 #include <door.h>
  29 #include <errno.h>
  30 #include <strings.h>
  31 #include <sys/mman.h>
  32 #include <libdladm.h>
  33 #include <libdlib.h>
  34 #include <libdllink.h>
  35 
  36 extern dladm_status_t   dladm_door_fd(dladm_handle_t, int *);
  37 
  38 static dladm_status_t
  39 ibd_dladm_door_call(dladm_handle_t handle, void *arg, size_t asize, void *rbuf,
  40     size_t rsize)
  41 {
  42         door_arg_t      darg;
  43         int             door_fd;
  44         dladm_status_t  status = DLADM_STATUS_OK;


  70         if (darg.rsize != rsize)
  71                 return (DLADM_STATUS_FAILED);
  72 
  73         if ((((dlmgmt_retval_t *)rbuf)->lr_err) == 0)
  74                 return (DLADM_STATUS_OK);
  75         else
  76                 return (DLADM_STATUS_FAILED);
  77 }
  78 
  79 static int
  80 ibd_delete_link(dladm_handle_t dlh, char *link)
  81 {
  82         dlmgmt_door_getlinkid_t         getlinkid;
  83         dlmgmt_getlinkid_retval_t       retval;
  84         datalink_id_t                   linkid;
  85         dladm_status_t                  status;
  86         char                            errmsg[DLADM_STRSIZE];
  87 
  88         getlinkid.ld_cmd = DLMGMT_CMD_GETLINKID;
  89         (void) strlcpy(getlinkid.ld_link, link, MAXLINKNAMELEN);
  90         getlinkid.ld_zoneid = -1;
  91 
  92         if ((status = ibd_dladm_door_call(dlh, &getlinkid, sizeof (getlinkid),
  93             &retval, sizeof (retval))) != DLADM_STATUS_OK) {
  94                 (void) fprintf(stderr,
  95                     "dladm_door_call failed: %s; linkname = %s\n",
  96                     dladm_status2str(status, errmsg), link);
  97                 return (status);
  98         }
  99 
 100         if (retval.lr_class != DATALINK_CLASS_PHYS) {
 101                 (void) fprintf(stderr,
 102                     "Not a physical link: linkname = %s, class = 0x%x\n",
 103                     link, (uint_t)retval.lr_class);
 104                 return (status);
 105         }
 106 
 107         linkid = retval.lr_linkid;
 108 
 109         if ((status = dladm_remove_conf(dlh, linkid)) != DLADM_STATUS_OK) {
 110                 (void) fprintf(stderr, "dladm_remove_conf failed: %s\n",