Deleted Added
full compact
if_ethersubr.c (151301) if_ethersubr.c (151305)
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 151301 2005-10-13 23:05:55Z thompsa $
30 * $FreeBSD: head/sys/net/if_ethersubr.c 151305 2005-10-14 02:38:47Z thompsa $
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_mac.h"
38#include "opt_netgraph.h"

--- 15 unchanged lines hidden (view full) ---

54#include <net/if_arp.h>
55#include <net/netisr.h>
56#include <net/route.h>
57#include <net/if_llc.h>
58#include <net/if_dl.h>
59#include <net/if_types.h>
60#include <net/bpf.h>
61#include <net/ethernet.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_mac.h"
38#include "opt_netgraph.h"

--- 15 unchanged lines hidden (view full) ---

54#include <net/if_arp.h>
55#include <net/netisr.h>
56#include <net/route.h>
57#include <net/if_llc.h>
58#include <net/if_dl.h>
59#include <net/if_types.h>
60#include <net/bpf.h>
61#include <net/ethernet.h>
62#include <net/if_bridgevar.h>
62#include <net/if_vlan_var.h>
63
64#if defined(INET) || defined(INET6)
65#include <netinet/in.h>
66#include <netinet/in_var.h>
67#include <netinet/if_ether.h>
68#include <netinet/ip_fw.h>
69#include <netinet/ip_dummynet.h>

--- 30 unchanged lines hidden (view full) ---

100void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp);
101void (*ng_ether_input_orphan_p)(struct ifnet *ifp, struct mbuf *m);
102int (*ng_ether_output_p)(struct ifnet *ifp, struct mbuf **mp);
103void (*ng_ether_attach_p)(struct ifnet *ifp);
104void (*ng_ether_detach_p)(struct ifnet *ifp);
105
106void (*vlan_input_p)(struct ifnet *, struct mbuf *);
107
63#include <net/if_vlan_var.h>
64
65#if defined(INET) || defined(INET6)
66#include <netinet/in.h>
67#include <netinet/in_var.h>
68#include <netinet/if_ether.h>
69#include <netinet/ip_fw.h>
70#include <netinet/ip_dummynet.h>

--- 30 unchanged lines hidden (view full) ---

101void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp);
102void (*ng_ether_input_orphan_p)(struct ifnet *ifp, struct mbuf *m);
103int (*ng_ether_output_p)(struct ifnet *ifp, struct mbuf **mp);
104void (*ng_ether_attach_p)(struct ifnet *ifp);
105void (*ng_ether_detach_p)(struct ifnet *ifp);
106
107void (*vlan_input_p)(struct ifnet *, struct mbuf *);
108
108/* if_bridge(4) support. XXX: should go into some include. */
109/* if_bridge(4) support */
109struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *);
110int (*bridge_output_p)(struct ifnet *, struct mbuf *,
111 struct sockaddr *, struct rtentry *);
112void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
113void (*bridge_detach_p)(struct ifnet *ifp);
114
115static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
116 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

--- 166 unchanged lines hidden (view full) ---

283 else
284 (void)memcpy(eh->ether_shost, IFP2ENADDR(ifp),
285 sizeof(eh->ether_shost));
286
287 /*
288 * Bridges require special output handling.
289 */
290 if (ifp->if_bridge) {
110struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *);
111int (*bridge_output_p)(struct ifnet *, struct mbuf *,
112 struct sockaddr *, struct rtentry *);
113void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
114void (*bridge_detach_p)(struct ifnet *ifp);
115
116static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
117 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

--- 166 unchanged lines hidden (view full) ---

284 else
285 (void)memcpy(eh->ether_shost, IFP2ENADDR(ifp),
286 sizeof(eh->ether_shost));
287
288 /*
289 * Bridges require special output handling.
290 */
291 if (ifp->if_bridge) {
291 KASSERT(bridge_output_p != NULL,
292 ("%s: if_bridge not loaded!", __func__));
293 return ((*bridge_output_p)(ifp, m, NULL, NULL));
292 BRIDGE_OUTPUT(ifp, m, error);
293 return (error);
294 }
295
296 /*
297 * If a simplex interface, and the packet is being sent to our
298 * Ethernet address or a broadcast address, loopback a copy.
299 * XXX To make a simplex device behave exactly like a duplex
300 * device, we should copy in the case of sending to our own
301 * ethernet address (thus letting the original actually appear

--- 278 unchanged lines hidden (view full) ---

580 * it gets processed as normal. Note that bridge_input()
581 * will always return the original packet if we need to
582 * process it locally.
583 *
584 * XXX: When changing the below block, please also look
585 * at the src/sys/netgraph/ng_ether.c:ng_ether_rcv_upper()
586 */
587 if (ifp->if_bridge) {
294 }
295
296 /*
297 * If a simplex interface, and the packet is being sent to our
298 * Ethernet address or a broadcast address, loopback a copy.
299 * XXX To make a simplex device behave exactly like a duplex
300 * device, we should copy in the case of sending to our own
301 * ethernet address (thus letting the original actually appear

--- 278 unchanged lines hidden (view full) ---

580 * it gets processed as normal. Note that bridge_input()
581 * will always return the original packet if we need to
582 * process it locally.
583 *
584 * XXX: When changing the below block, please also look
585 * at the src/sys/netgraph/ng_ether.c:ng_ether_rcv_upper()
586 */
587 if (ifp->if_bridge) {
588 KASSERT(bridge_input_p != NULL,
589 ("%s: if_bridge not loaded!", __func__));
590
591 m = (*bridge_input_p)(ifp, m);
588 BRIDGE_INPUT(ifp, m);
592 if (m == NULL)
593 return;
589 if (m == NULL)
590 return;
594 /*
595 * Bridge has determined that the packet is for us.
596 * Update our interface pointer -- we may have had
597 * to "bridge" the packet locally.
598 */
599 ifp = m->m_pkthdr.rcvif;
600 }
601
602 /* First chunk of an mbuf contains good entropy */
603 if (harvest.ethernet)
604 random_harvest(m, 16, 3, 0, RANDOM_NET);
605 ether_demux(ifp, m);
606}
607

--- 599 unchanged lines hidden ---
591 }
592
593 /* First chunk of an mbuf contains good entropy */
594 if (harvest.ethernet)
595 random_harvest(m, 16, 3, 0, RANDOM_NET);
596 ether_demux(ifp, m);
597}
598

--- 599 unchanged lines hidden ---