if_ethersubr.c (191148) | if_ethersubr.c (191816) |
---|---|
1/*- 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 | 1/*- 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 |
30 * $FreeBSD: head/sys/net/if_ethersubr.c 191148 2009-04-16 20:30:28Z kmacy $ | 30 * $FreeBSD: head/sys/net/if_ethersubr.c 191816 2009-05-05 10:56:12Z zec $ |
31 */ 32 33#include "opt_atalk.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipx.h" 37#include "opt_route.h" 38#include "opt_mac.h" --- 558 unchanged lines hidden (view full) --- 597 } 598#ifdef DIAGNOSTIC 599 if (m->m_pkthdr.rcvif != ifp) { 600 if_printf(ifp, "Warning, frame marked as received on %s\n", 601 m->m_pkthdr.rcvif->if_xname); 602 } 603#endif 604 | 31 */ 32 33#include "opt_atalk.h" 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipx.h" 37#include "opt_route.h" 38#include "opt_mac.h" --- 558 unchanged lines hidden (view full) --- 597 } 598#ifdef DIAGNOSTIC 599 if (m->m_pkthdr.rcvif != ifp) { 600 if_printf(ifp, "Warning, frame marked as received on %s\n", 601 m->m_pkthdr.rcvif->if_xname); 602 } 603#endif 604 |
605 CURVNET_SET_QUIET(ifp->if_vnet); 606 |
|
605 if (ETHER_IS_MULTICAST(eh->ether_dhost)) { 606 if (ETHER_IS_BROADCAST(eh->ether_dhost)) 607 m->m_flags |= M_BCAST; 608 else 609 m->m_flags |= M_MCAST; 610 ifp->if_imcasts++; 611 } 612 --- 20 unchanged lines hidden (view full) --- 633 m->m_flags &= ~M_HASFCS; 634 } 635 636 ifp->if_ibytes += m->m_pkthdr.len; 637 638 /* Allow monitor mode to claim this frame, after stats are updated. */ 639 if (ifp->if_flags & IFF_MONITOR) { 640 m_freem(m); | 607 if (ETHER_IS_MULTICAST(eh->ether_dhost)) { 608 if (ETHER_IS_BROADCAST(eh->ether_dhost)) 609 m->m_flags |= M_BCAST; 610 else 611 m->m_flags |= M_MCAST; 612 ifp->if_imcasts++; 613 } 614 --- 20 unchanged lines hidden (view full) --- 635 m->m_flags &= ~M_HASFCS; 636 } 637 638 ifp->if_ibytes += m->m_pkthdr.len; 639 640 /* Allow monitor mode to claim this frame, after stats are updated. */ 641 if (ifp->if_flags & IFF_MONITOR) { 642 m_freem(m); |
643 CURVNET_RESTORE(); |
|
641 return; 642 } 643 644 /* Handle input from a lagg(4) port */ 645 if (ifp->if_type == IFT_IEEE8023ADLAG) { 646 KASSERT(lagg_input_p != NULL, 647 ("%s: if_lagg not loaded!", __func__)); 648 m = (*lagg_input_p)(ifp, m); --- 32 unchanged lines hidden (view full) --- 681 } 682 683 /* Allow ng_ether(4) to claim this frame. */ 684 if (IFP2AC(ifp)->ac_netgraph != NULL) { 685 KASSERT(ng_ether_input_p != NULL, 686 ("%s: ng_ether_input_p is NULL", __func__)); 687 m->m_flags &= ~M_PROMISC; 688 (*ng_ether_input_p)(ifp, &m); | 644 return; 645 } 646 647 /* Handle input from a lagg(4) port */ 648 if (ifp->if_type == IFT_IEEE8023ADLAG) { 649 KASSERT(lagg_input_p != NULL, 650 ("%s: if_lagg not loaded!", __func__)); 651 m = (*lagg_input_p)(ifp, m); --- 32 unchanged lines hidden (view full) --- 684 } 685 686 /* Allow ng_ether(4) to claim this frame. */ 687 if (IFP2AC(ifp)->ac_netgraph != NULL) { 688 KASSERT(ng_ether_input_p != NULL, 689 ("%s: ng_ether_input_p is NULL", __func__)); 690 m->m_flags &= ~M_PROMISC; 691 (*ng_ether_input_p)(ifp, &m); |
689 if (m == NULL) | 692 if (m == NULL) { 693 CURVNET_RESTORE(); |
690 return; | 694 return; |
695 } |
|
691 } 692 693 /* 694 * Allow if_bridge(4) to claim this frame. 695 * The BRIDGE_INPUT() macro will update ifp if the bridge changed it 696 * and the frame should be delivered locally. 697 */ 698 if (ifp->if_bridge != NULL) { 699 m->m_flags &= ~M_PROMISC; 700 BRIDGE_INPUT(ifp, m); | 696 } 697 698 /* 699 * Allow if_bridge(4) to claim this frame. 700 * The BRIDGE_INPUT() macro will update ifp if the bridge changed it 701 * and the frame should be delivered locally. 702 */ 703 if (ifp->if_bridge != NULL) { 704 m->m_flags &= ~M_PROMISC; 705 BRIDGE_INPUT(ifp, m); |
701 if (m == NULL) | 706 if (m == NULL) { 707 CURVNET_RESTORE(); |
702 return; | 708 return; |
709 } |
|
703 } 704 705#ifdef DEV_CARP 706 /* 707 * Clear M_PROMISC on frame so that carp(4) will see it when the 708 * mbuf flows up to Layer 3. 709 * FreeBSD's implementation of carp(4) uses the inprotosw 710 * to dispatch IPPROTO_CARP. carp(4) also allocates its own --- 19 unchanged lines hidden (view full) --- 730 m->m_flags |= M_PROMISC; 731 } 732 733 /* First chunk of an mbuf contains good entropy */ 734 if (harvest.ethernet) 735 random_harvest(m, 16, 3, 0, RANDOM_NET); 736 737 ether_demux(ifp, m); | 710 } 711 712#ifdef DEV_CARP 713 /* 714 * Clear M_PROMISC on frame so that carp(4) will see it when the 715 * mbuf flows up to Layer 3. 716 * FreeBSD's implementation of carp(4) uses the inprotosw 717 * to dispatch IPPROTO_CARP. carp(4) also allocates its own --- 19 unchanged lines hidden (view full) --- 737 m->m_flags |= M_PROMISC; 738 } 739 740 /* First chunk of an mbuf contains good entropy */ 741 if (harvest.ethernet) 742 random_harvest(m, 16, 3, 0, RANDOM_NET); 743 744 ether_demux(ifp, m); |
745 CURVNET_RESTORE(); |
|
738} 739 740/* 741 * Upper layer processing for a received Ethernet packet. 742 */ 743void 744ether_demux(struct ifnet *ifp, struct mbuf *m) 745{ --- 581 unchanged lines hidden --- | 746} 747 748/* 749 * Upper layer processing for a received Ethernet packet. 750 */ 751void 752ether_demux(struct ifnet *ifp, struct mbuf *m) 753{ --- 581 unchanged lines hidden --- |