Print this page
10543 dls_unbind() needs better checking
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: Dan McDonald <danmcd@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/dls/dls.c
          +++ new/usr/src/uts/common/io/dls/dls.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   * Copyright 2012, Nexenta Systems, Inc. All rights reserved.
  25   25   */
  26   26  
  27   27  /*
  28      - * Copyright (c) 2013 Joyent, Inc.  All rights reserved.
       28 + * Copyright (c) 2019 Joyent, Inc.  All rights reserved.
  29   29   */
  30   30  
  31   31  /*
  32   32   * Data-Link Services Module
  33   33   */
  34   34  
  35   35  #include        <sys/strsun.h>
  36   36  #include        <sys/vlan.h>
  37   37  #include        <sys/dld_impl.h>
  38   38  #include        <sys/mac_client_priv.h>
↓ open down ↓ 172 lines elided ↑ open up ↑
 211  211  
 212  212  void
 213  213  dls_unbind(dld_str_t *dsp)
 214  214  {
 215  215          ASSERT(MAC_PERIM_HELD(dsp->ds_mh));
 216  216  
 217  217          if (dsp->ds_nonip && --dsp->ds_dlp->dl_nonip_cnt == 0)
 218  218                  mac_rx_bypass_enable(dsp->ds_mch);
 219  219  
 220  220          /*
 221      -         * For VLAN SAP, there was a promisc handle registered when dls_bind.
 222      -         * When unbind this dls link, we need to remove the promisc handle.
 223      -         * See comments in dls_bind().
      221 +         * A VLAN SAP does not actually add itself to the STREAM head today.
      222 +         * While we initially set up a VLAN handle below, it's possible that
      223 +         * something else will have come in and clobberd it.
 224  224           */
 225      -        if (dsp->ds_vlan_mph != NULL) {
 226      -                mac_promisc_remove(dsp->ds_vlan_mph);
 227      -                dsp->ds_vlan_mph = NULL;
      225 +        if (dsp->ds_sap == ETHERTYPE_VLAN) {
      226 +                if (dsp->ds_vlan_mph != NULL) {
      227 +                        mac_promisc_remove(dsp->ds_vlan_mph);
      228 +                        dsp->ds_vlan_mph = NULL;
      229 +                }
 228  230                  return;
 229  231          }
 230  232  
 231  233          /*
 232  234           * Unbind the dld_str_t by removing it from the hash table in the
 233  235           * dls_link_t.
 234  236           */
 235  237          dls_link_remove(dsp->ds_dlp, dsp);
 236  238          dsp->ds_sap = 0;
 237  239  }
↓ open down ↓ 494 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX