Print this page
10052 "dladm show-ether" should pick one kstat snapshot and stick with it
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gergo Doma <domag02@gmail.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdladm/common/libdladm.c
          +++ new/usr/src/lib/libdladm/common/libdladm.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   */
  24   24  
       25 +/*
       26 + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
       27 + */
       28 +
  25   29  #include <unistd.h>
  26   30  #include <errno.h>
  27   31  #include <ctype.h>
  28   32  #include <fcntl.h>
  29   33  #include <strings.h>
  30   34  #include <dirent.h>
  31   35  #include <stdlib.h>
  32   36  #include <netinet/in.h>
  33   37  #include <arpa/inet.h>
  34   38  #include <sys/param.h>
↓ open down ↓ 79 lines elided ↑ open up ↑
 114  118           * to dladm_door_fd() for all cases.
 115  119           */
 116  120  
 117  121          if ((*handle = malloc(sizeof (struct dladm_handle))) == NULL) {
 118  122                  (void) close(dld_fd);
 119  123                  return (DLADM_STATUS_NOMEM);
 120  124          }
 121  125  
 122  126          (*handle)->dld_fd = dld_fd;
 123  127          (*handle)->door_fd = -1;
      128 +        (*handle)->dld_kcp = NULL;
 124  129  
 125  130          return (DLADM_STATUS_OK);
 126  131  }
 127  132  
 128  133  void
 129  134  dladm_close(dladm_handle_t handle)
 130  135  {
 131  136          if (handle != NULL) {
 132  137                  (void) close(handle->dld_fd);
 133  138                  if (handle->door_fd != -1)
 134  139                          (void) close(handle->door_fd);
      140 +                if (handle->dld_kcp != NULL)
      141 +                        (void) kstat_close(handle->dld_kcp);
 135  142                  free(handle);
 136  143          }
 137  144  }
 138  145  
 139  146  int
 140  147  dladm_dld_fd(dladm_handle_t handle)
 141  148  {
 142  149          return (handle->dld_fd);
 143  150  }
 144  151  
      152 +kstat_ctl_t *
      153 +dladm_dld_kcp(dladm_handle_t handle)
      154 +{
      155 +        if (handle->dld_kcp == NULL)
      156 +                handle->dld_kcp = kstat_open();
      157 +        return (handle->dld_kcp);
      158 +}
      159 +
 145  160  /*
 146  161   * If DLMGMT_DOOR hasn't been opened in the handle yet, open it.
 147  162   */
 148  163  dladm_status_t
 149  164  dladm_door_fd(dladm_handle_t handle, int *door_fd)
 150  165  {
 151  166          int fd;
 152  167  
 153  168          if (handle->door_fd == -1) {
 154  169                  if ((fd = open(DLMGMT_DOOR, O_RDONLY)) < 0)
↓ open down ↓ 1123 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX