Print this page
9832 Original bug discovered as 9560 has friends IPv4 packets coming in as IPv6 creating chaos


   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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2017 Joyent, Inc.
  25  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 /*
  29  * MAC data path
  30  *
  31  * The MAC data path is concerned with the flow of traffic from mac clients --
  32  * DLS, IP, etc. -- to various GLDv3 device drivers -- e1000g, vnic, aggr,
  33  * ixgbe, etc. -- and from the GLDv3 device drivers back to clients.
  34  *
  35  * -----------
  36  * Terminology
  37  * -----------
  38  *
  39  * MAC uses a lot of different, but related terms that are associated with the
  40  * design and structure of the data path. Before we cover other aspects, first
  41  * let's review the terminology that MAC uses.
  42  *
  43  * MAC
  44  *


1772                 *indx = 0;
1773                 *type = OTH;
1774                 fanout_unaligned++;
1775                 return (0);
1776         }
1777 
1778         /*
1779          * Extract next-header, full header length, and source-hash value
1780          * using v4/v6 specific fields.
1781          */
1782         if (v6) {
1783                 remlen = ntohs(ip6h->ip6_plen);
1784                 nexthdr = ip6h->ip6_nxt;
1785                 src_val = V4_PART_OF_V6(ip6h->ip6_src);
1786                 dst_val = V4_PART_OF_V6(ip6h->ip6_dst);
1787                 /*
1788                  * Do src based fanout if below tunable is set to B_TRUE or
1789                  * when mac_ip_hdr_length_v6() fails because of malformed
1790                  * packets or because mblks need to be concatenated using
1791                  * pullupmsg().
1792                  *
1793                  * Perform a version check to prevent parsing weirdness...
1794                  */
1795                 if (IPH_HDR_VERSION(ip6h) != IPV6_VERSION ||
1796                     !mac_ip_hdr_length_v6(ip6h, mp->b_wptr, &hdr_len, &nexthdr,
1797                     NULL)) {
1798                         goto src_dst_based_fanout;
1799                 }
1800         } else {
1801                 hdr_len = IPH_HDR_LENGTH(ipha);
1802                 remlen = ntohs(ipha->ipha_length) - hdr_len;
1803                 nexthdr = ipha->ipha_protocol;
1804                 src_val = (uint32_t)ipha->ipha_src;
1805                 dst_val = (uint32_t)ipha->ipha_dst;
1806                 /*
1807                  * Catch IPv4 fragment case here.  IPv6 has nexthdr == FRAG
1808                  * for its equivalent case.
1809                  */
1810                 if ((ntohs(ipha->ipha_fragment_offset_and_flags) &
1811                     (IPH_MF | IPH_OFFSET)) != 0) {
1812                         goto src_dst_based_fanout;
1813                 }
1814         }
1815         if (remlen < MIN_EHDR_LEN)
1816                 return (-1);




   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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2018 Joyent, Inc.
  25  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 /*
  29  * MAC data path
  30  *
  31  * The MAC data path is concerned with the flow of traffic from mac clients --
  32  * DLS, IP, etc. -- to various GLDv3 device drivers -- e1000g, vnic, aggr,
  33  * ixgbe, etc. -- and from the GLDv3 device drivers back to clients.
  34  *
  35  * -----------
  36  * Terminology
  37  * -----------
  38  *
  39  * MAC uses a lot of different, but related terms that are associated with the
  40  * design and structure of the data path. Before we cover other aspects, first
  41  * let's review the terminology that MAC uses.
  42  *
  43  * MAC
  44  *


1772                 *indx = 0;
1773                 *type = OTH;
1774                 fanout_unaligned++;
1775                 return (0);
1776         }
1777 
1778         /*
1779          * Extract next-header, full header length, and source-hash value
1780          * using v4/v6 specific fields.
1781          */
1782         if (v6) {
1783                 remlen = ntohs(ip6h->ip6_plen);
1784                 nexthdr = ip6h->ip6_nxt;
1785                 src_val = V4_PART_OF_V6(ip6h->ip6_src);
1786                 dst_val = V4_PART_OF_V6(ip6h->ip6_dst);
1787                 /*
1788                  * Do src based fanout if below tunable is set to B_TRUE or
1789                  * when mac_ip_hdr_length_v6() fails because of malformed
1790                  * packets or because mblks need to be concatenated using
1791                  * pullupmsg().


1792                  */
1793                 if (!mac_ip_hdr_length_v6(ip6h, mp->b_wptr, &hdr_len, &nexthdr,

1794                     NULL)) {
1795                         goto src_dst_based_fanout;
1796                 }
1797         } else {
1798                 hdr_len = IPH_HDR_LENGTH(ipha);
1799                 remlen = ntohs(ipha->ipha_length) - hdr_len;
1800                 nexthdr = ipha->ipha_protocol;
1801                 src_val = (uint32_t)ipha->ipha_src;
1802                 dst_val = (uint32_t)ipha->ipha_dst;
1803                 /*
1804                  * Catch IPv4 fragment case here.  IPv6 has nexthdr == FRAG
1805                  * for its equivalent case.
1806                  */
1807                 if ((ntohs(ipha->ipha_fragment_offset_and_flags) &
1808                     (IPH_MF | IPH_OFFSET)) != 0) {
1809                         goto src_dst_based_fanout;
1810                 }
1811         }
1812         if (remlen < MIN_EHDR_LEN)
1813                 return (-1);