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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2017 Joyent, Inc.
25 */
26
27 /*
28 * Data-Link Services Module
29 */
30
31 #include <sys/sysmacros.h>
32 #include <sys/strsubr.h>
33 #include <sys/strsun.h>
34 #include <sys/vlan.h>
35 #include <sys/dld_impl.h>
36 #include <sys/sdt.h>
37 #include <sys/atomic.h>
38 #include <sys/sysevent.h>
39 #include <sys/sysevent/eventdefs.h>
40 #include <sys/sysevent/datalink.h>
41
42 static kmem_cache_t *i_dls_link_cachep;
43 mod_hash_t *i_dls_link_hash;
44 static uint_t i_dls_link_count;
365 accepted = B_FALSE;
366
367 DLS_PREPARE_PKT(dlp->dl_mh, mp, &mhi, err);
368 if (err != 0) {
369 atomic_inc_32(&(dlp->dl_unknowns));
370 nextp = mp->b_next;
371 mp->b_next = NULL;
372 freemsg(mp);
373 continue;
374 }
375
376 /*
377 * Grab the longest sub-chain we can process as a single
378 * unit.
379 */
380 nextp = i_dls_link_subchain(dlp, mp, &mhi, &npacket);
381 ASSERT(npacket != 0);
382
383 vid = VLAN_ID(mhi.mhi_tci);
384
385 if (mhi.mhi_istagged) {
386 /*
387 * If it is tagged traffic, send it upstream to
388 * all dld_str_t which are attached to the physical
389 * link and bound to SAP 0x8100.
390 */
391 if (i_dls_link_rx_func(dlp, mrh, &mhi, mp,
392 ETHERTYPE_VLAN, dls_accept) > 0) {
393 accepted = B_TRUE;
394 }
395
396 /*
397 * Don't pass the packets up if they are tagged
398 * packets and:
399 * - their VID and priority are both zero and the
400 * original packet isn't using the PVID (invalid
401 * packets).
402 * - their sap is ETHERTYPE_VLAN and their VID is
403 * zero as they have already been sent upstreams.
404 */
405 if ((vid == VLAN_ID_NONE && !mhi.mhi_ispvid &&
|
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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2018 Joyent, Inc.
25 */
26
27 /*
28 * Data-Link Services Module
29 */
30
31 #include <sys/sysmacros.h>
32 #include <sys/strsubr.h>
33 #include <sys/strsun.h>
34 #include <sys/vlan.h>
35 #include <sys/dld_impl.h>
36 #include <sys/sdt.h>
37 #include <sys/atomic.h>
38 #include <sys/sysevent.h>
39 #include <sys/sysevent/eventdefs.h>
40 #include <sys/sysevent/datalink.h>
41
42 static kmem_cache_t *i_dls_link_cachep;
43 mod_hash_t *i_dls_link_hash;
44 static uint_t i_dls_link_count;
365 accepted = B_FALSE;
366
367 DLS_PREPARE_PKT(dlp->dl_mh, mp, &mhi, err);
368 if (err != 0) {
369 atomic_inc_32(&(dlp->dl_unknowns));
370 nextp = mp->b_next;
371 mp->b_next = NULL;
372 freemsg(mp);
373 continue;
374 }
375
376 /*
377 * Grab the longest sub-chain we can process as a single
378 * unit.
379 */
380 nextp = i_dls_link_subchain(dlp, mp, &mhi, &npacket);
381 ASSERT(npacket != 0);
382
383 vid = VLAN_ID(mhi.mhi_tci);
384
385 /*
386 * This condition is true only when a sun4v vsw client
387 * is on the scene; as it is the only type of client
388 * that multiplexes VLANs on a single client instance.
389 * All other types of clients have one VLAN per client
390 * instance. In that case, MAC strips the VLAN tag
391 * before delivering it to DLS (see mac_rx_deliver()).
392 */
393 if (mhi.mhi_istagged) {
394
395 /*
396 * If it is tagged traffic, send it upstream to
397 * all dld_str_t which are attached to the physical
398 * link and bound to SAP 0x8100.
399 */
400 if (i_dls_link_rx_func(dlp, mrh, &mhi, mp,
401 ETHERTYPE_VLAN, dls_accept) > 0) {
402 accepted = B_TRUE;
403 }
404
405 /*
406 * Don't pass the packets up if they are tagged
407 * packets and:
408 * - their VID and priority are both zero and the
409 * original packet isn't using the PVID (invalid
410 * packets).
411 * - their sap is ETHERTYPE_VLAN and their VID is
412 * zero as they have already been sent upstreams.
413 */
414 if ((vid == VLAN_ID_NONE && !mhi.mhi_ispvid &&
|