if_ethersubr.c (142069) | if_ethersubr.c (142215) |
---|---|
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 142069 2005-02-18 22:31:19Z ru $ | 30 * $FreeBSD: head/sys/net/if_ethersubr.c 142215 2005-02-22 13:04:05Z glebius $ |
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_bdg.h" 38#include "opt_mac.h" 39#include "opt_netgraph.h" | 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_bdg.h" 38#include "opt_mac.h" 39#include "opt_netgraph.h" |
40#include "opt_carp.h" |
|
40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/kernel.h> 44#include <sys/mac.h> 45#include <sys/malloc.h> 46#include <sys/module.h> 47#include <sys/mbuf.h> --- 20 unchanged lines hidden (view full) --- 68#include <netinet/if_ether.h> 69#include <netinet/ip_fw.h> 70#include <netinet/ip_dummynet.h> 71#endif 72#ifdef INET6 73#include <netinet6/nd6.h> 74#endif 75 | 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> 47#include <sys/module.h> 48#include <sys/mbuf.h> --- 20 unchanged lines hidden (view full) --- 69#include <netinet/if_ether.h> 70#include <netinet/ip_fw.h> 71#include <netinet/ip_dummynet.h> 72#endif 73#ifdef INET6 74#include <netinet6/nd6.h> 75#endif 76 |
77#ifdef DEV_CARP 78#include <netinet/ip_carp.h> 79#endif 80 |
|
76#ifdef IPX 77#include <netipx/ipx.h> 78#include <netipx/ipx_if.h> 79int (*ef_inputp)(struct ifnet*, struct ether_header *eh, struct mbuf *m); 80int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, 81 struct sockaddr *dst, short *tp, int *hlen); 82#endif 83 --- 226 unchanged lines hidden (view full) --- 310 m->m_pkthdr.csum_flags |= csum_flags; 311 if (csum_flags & CSUM_DATA_VALID) 312 m->m_pkthdr.csum_data = 0xffff; 313 (void) if_simloop(ifp, m, dst->sa_family, hlen); 314 return (0); /* XXX */ 315 } 316 } 317 | 81#ifdef IPX 82#include <netipx/ipx.h> 83#include <netipx/ipx_if.h> 84int (*ef_inputp)(struct ifnet*, struct ether_header *eh, struct mbuf *m); 85int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, 86 struct sockaddr *dst, short *tp, int *hlen); 87#endif 88 --- 226 unchanged lines hidden (view full) --- 315 m->m_pkthdr.csum_flags |= csum_flags; 316 if (csum_flags & CSUM_DATA_VALID) 317 m->m_pkthdr.csum_data = 0xffff; 318 (void) if_simloop(ifp, m, dst->sa_family, hlen); 319 return (0); /* XXX */ 320 } 321 } 322 |
323#ifdef DEV_CARP 324 if (ifp->if_carp && 325 (error = carp_output(ifp, m, dst, NULL))) 326 goto bad; 327#endif 328 |
|
318 /* Handle ng_ether(4) processing, if any */ 319 if (IFP2AC(ifp)->ac_netgraph != NULL) { 320 if ((error = (*ng_ether_output_p)(ifp, &m)) != 0) { 321bad: if (m != NULL) 322 m_freem(m); 323 return (error); 324 } 325 if (m == NULL) --- 275 unchanged lines hidden (view full) --- 601#if defined(INET) || defined(INET6) 602 if (rule) /* packet was already bridged */ 603 goto post_stats; 604#endif 605 606 if (!(BDG_ACTIVE(ifp)) && 607 !((ether_type == ETHERTYPE_VLAN || m->m_flags & M_VLANTAG) && 608 ifp->if_nvlans > 0)) { | 329 /* Handle ng_ether(4) processing, if any */ 330 if (IFP2AC(ifp)->ac_netgraph != NULL) { 331 if ((error = (*ng_ether_output_p)(ifp, &m)) != 0) { 332bad: if (m != NULL) 333 m_freem(m); 334 return (error); 335 } 336 if (m == NULL) --- 275 unchanged lines hidden (view full) --- 612#if defined(INET) || defined(INET6) 613 if (rule) /* packet was already bridged */ 614 goto post_stats; 615#endif 616 617 if (!(BDG_ACTIVE(ifp)) && 618 !((ether_type == ETHERTYPE_VLAN || m->m_flags & M_VLANTAG) && 619 ifp->if_nvlans > 0)) { |
620#ifdef DEV_CARP |
|
609 /* | 621 /* |
622 * XXX: Okay, we need to call carp_forus() and - if it is for us 623 * jump over code that does the normal check 624 * "ac_enaddr == ether_dhost". The check sequence is a bit 625 * different from OpenBSD, so we jump over as few code as possible, 626 * to catch _all_ sanity checks. This needs evaluation, to see if 627 * the carp ether_dhost values break any of these checks! 628 */ 629 if (ifp->if_carp && carp_forus(ifp->if_carp, eh->ether_dhost)) 630 goto pre_stats; 631#endif 632 /* |
|
610 * Discard packet if upper layers shouldn't see it because it 611 * was unicast to a different Ethernet address. If the driver 612 * is working properly, then this situation can only happen 613 * when the interface is in promiscuous mode. 614 * 615 * If VLANs are active, and this packet has a VLAN tag, do 616 * not drop it here but pass it on to the VLAN layer, to 617 * give them a chance to consider it as well (e. g. in case --- 5 unchanged lines hidden (view full) --- 623 && bcmp(eh->ether_dhost, 624 IFP2AC(ifp)->ac_enaddr, ETHER_ADDR_LEN) != 0 625 && (ifp->if_flags & IFF_PPROMISC) == 0) { 626 m_freem(m); 627 return; 628 } 629 } 630 | 633 * Discard packet if upper layers shouldn't see it because it 634 * was unicast to a different Ethernet address. If the driver 635 * is working properly, then this situation can only happen 636 * when the interface is in promiscuous mode. 637 * 638 * If VLANs are active, and this packet has a VLAN tag, do 639 * not drop it here but pass it on to the VLAN layer, to 640 * give them a chance to consider it as well (e. g. in case --- 5 unchanged lines hidden (view full) --- 646 && bcmp(eh->ether_dhost, 647 IFP2AC(ifp)->ac_enaddr, ETHER_ADDR_LEN) != 0 648 && (ifp->if_flags & IFF_PPROMISC) == 0) { 649 m_freem(m); 650 return; 651 } 652 } 653 |
654#ifdef DEV_CARP 655pre_stats: 656#endif |
|
631 /* Discard packet if interface is not up */ 632 if ((ifp->if_flags & IFF_UP) == 0) { 633 m_freem(m); 634 return; 635 } 636 if (ETHER_IS_MULTICAST(eh->ether_dhost)) { 637 if (bcmp(etherbroadcastaddr, eh->ether_dhost, 638 sizeof(etherbroadcastaddr)) == 0) --- 478 unchanged lines hidden --- | 657 /* Discard packet if interface is not up */ 658 if ((ifp->if_flags & IFF_UP) == 0) { 659 m_freem(m); 660 return; 661 } 662 if (ETHER_IS_MULTICAST(eh->ether_dhost)) { 663 if (bcmp(etherbroadcastaddr, eh->ether_dhost, 664 sizeof(etherbroadcastaddr)) == 0) --- 478 unchanged lines hidden --- |