Print this page
9832 Original bug discovered as 9560 has friends IPv4 packets coming in as IPv6 creating chaos
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/mac_impl.h
          +++ new/usr/src/uts/common/sys/mac_impl.h
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  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      - * Copyright (c) 2017, Joyent, Inc.
       23 + * Copyright (c) 2019, Joyent, Inc.
  24   24   */
  25   25  
  26   26  #ifndef _SYS_MAC_IMPL_H
  27   27  #define _SYS_MAC_IMPL_H
  28   28  
  29   29  #include <sys/cpupart.h>
  30   30  #include <sys/modhash.h>
  31   31  #include <sys/mac_client.h>
  32   32  #include <sys/mac_provider.h>
  33   33  #include <sys/note.h>
↓ open down ↓ 203 lines elided ↑ open up ↑
 237  237          (mr)->mr_flag &= ~flag;
 238  238  
 239  239  /*
 240  240   * Reference hold and release on mac_ring_t 'mr'
 241  241   */
 242  242  #define MR_REFHOLD_LOCKED(mr)           {               \
 243  243          ASSERT(MUTEX_HELD(&mr->mr_lock));               \
 244  244          (mr)->mr_refcnt++;                              \
 245  245  }
 246  246  
 247      -#define MR_REFRELE(mr)          {                       \
      247 +#define MR_REFRELE(mr)          {                       \
 248  248          mutex_enter(&(mr)->mr_lock);                    \
 249  249          ASSERT((mr)->mr_refcnt != 0);                   \
 250  250          (mr)->mr_refcnt--;                              \
 251  251          if ((mr)->mr_refcnt == 0 &&                     \
 252  252              ((mr)->mr_flag & (MR_CONDEMNED | MR_QUIESCE))) \
 253  253                  cv_signal(&(mr)->mr_cv);                \
 254  254          mutex_exit(&(mr)->mr_lock);                     \
 255  255  }
 256  256  
 257  257  /*
↓ open down ↓ 35 lines elided ↑ open up ↑
 293  293  #define mrg_stop                mrg_info.mgi_stop
 294  294  
 295  295  #define GROUP_INTR_HANDLE(g)            (g)->mrg_info.mgi_intr.mi_handle
 296  296  #define GROUP_INTR_ENABLE_FUNC(g)       (g)->mrg_info.mgi_intr.mi_enable
 297  297  #define GROUP_INTR_DISABLE_FUNC(g)      (g)->mrg_info.mgi_intr.mi_disable
 298  298  
 299  299  #define MAC_RING_TX(mhp, rh, mp, rest) {                                \
 300  300          mac_ring_handle_t mrh = rh;                                     \
 301  301          mac_impl_t *mimpl = (mac_impl_t *)mhp;                          \
 302  302          /*                                                              \
 303      -         * Send packets through a selected tx ring, or through the      \
      303 +         * Send packets through a selected tx ring, or through the      \
 304  304           * default handler if there is no selected ring.                \
 305  305           */                                                             \
 306  306          if (mrh == NULL)                                                \
 307  307                  mrh = mimpl->mi_default_tx_ring;                        \
 308  308          if (mrh == NULL) {                                              \
 309  309                  rest = mimpl->mi_tx(mimpl->mi_driver, mp);              \
 310  310          } else {                                                        \
 311  311                  rest = mac_hwring_tx(mrh, mp);                          \
 312  312          }                                                               \
 313  313  }
↓ open down ↓ 1 lines elided ↑ open up ↑
 315  315  /*
 316  316   * This is the final stop before reaching the underlying driver
 317  317   * or aggregation, so this is where the bridging hook is implemented.
 318  318   * Packets that are bridged will return through mac_bridge_tx(), with
 319  319   * rh nulled out if the bridge chooses to send output on a different
 320  320   * link due to forwarding.
 321  321   */
 322  322  #define MAC_TX(mip, rh, mp, src_mcip) {                                 \
 323  323          mac_ring_handle_t       rhandle = (rh);                         \
 324  324          /*                                                              \
 325      -         * If there is a bound Hybrid I/O share, send packets through   \
      325 +         * If there is a bound Hybrid I/O share, send packets through   \
 326  326           * the default tx ring. (When there's a bound Hybrid I/O share, \
 327      -         * the tx rings of this client are mapped in the guest domain   \
      327 +         * the tx rings of this client are mapped in the guest domain   \
 328  328           * and not accessible from here.)                               \
 329  329           */                                                             \
 330  330          _NOTE(CONSTANTCONDITION)                                        \
 331  331          if ((src_mcip)->mci_state_flags & MCIS_SHARE_BOUND)             \
 332  332                  rhandle = (mip)->mi_default_tx_ring;                    \
 333  333          if (mip->mi_promisc_list != NULL)                               \
 334  334                  mac_promisc_dispatch(mip, mp, src_mcip);                \
 335  335          /*                                                              \
 336      -         * Grab the proper transmit pointer and handle. Special         \
      336 +         * Grab the proper transmit pointer and handle. Special         \
 337  337           * optimization: we can test mi_bridge_link itself atomically,  \
 338  338           * and if that indicates no bridge send packets through tx ring.\
 339  339           */                                                             \
 340  340          if (mip->mi_bridge_link == NULL) {                              \
 341  341                  MAC_RING_TX(mip, rhandle, mp, mp);                      \
 342  342          } else {                                                        \
 343  343                  mp = mac_bridge_tx(mip, rhandle, mp);                   \
 344  344          }                                                               \
 345  345  }
 346  346  
↓ open down ↓ 369 lines elided ↑ open up ↑
 716  716          fe_resource_props.mrp_mask & MRP_PROTECT) != 0 && \
 717  717          ((mcip)->mci_flent-> \
 718  718          fe_resource_props.mrp_protect.mp_types & (type)) != 0)
 719  719  
 720  720  typedef struct mac_client_impl_s mac_client_impl_t;
 721  721  
 722  722  extern void     mac_init(void);
 723  723  extern int      mac_fini(void);
 724  724  
 725  725  extern void     mac_ndd_ioctl(mac_impl_t *, queue_t *, mblk_t *);
 726      -extern boolean_t mac_ip_hdr_length_v6(ip6_t *, uint8_t *, uint16_t *,
      726 +extern int mac_ip_hdr_length_v6(ip6_t *, uint8_t *, uint16_t *,
 727  727      uint8_t *, ip6_frag_t **);
 728  728  
 729  729  extern mblk_t *mac_copymsgchain_cksum(mblk_t *);
 730  730  extern mblk_t *mac_fix_cksum(mblk_t *);
 731  731  extern void mac_packet_print(mac_handle_t, mblk_t *);
 732  732  extern void mac_rx_deliver(void *, mac_resource_handle_t, mblk_t *,
 733  733      mac_header_info_t *);
 734  734  extern void mac_tx_notify(mac_impl_t *);
 735  735  
 736  736  extern  boolean_t mac_callback_find(mac_cb_info_t *, mac_cb_t **, mac_cb_t *);
↓ open down ↓ 204 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX