Deleted Added
sdiff udiff text old ( 191148 ) new ( 241610 )
full compact
1/*-
2 * Copyright (c) 1982, 1986, 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 * From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93
30 * $FreeBSD: head/sys/net/if_disc.c 191148 2009-04-16 20:30:28Z kmacy $
31 */
32
33/*
34 * Discard interface driver for protocol testing and timing.
35 * (Based on the loopback.)
36 */
37
38#include <sys/param.h>

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

54#include "opt_inet6.h"
55
56#ifdef TINY_DSMTU
57#define DSMTU (1024+512)
58#else
59#define DSMTU 65532
60#endif
61
62#define DISCNAME "disc"
63
64struct disc_softc {
65 struct ifnet *sc_ifp;
66};
67
68static int discoutput(struct ifnet *, struct mbuf *,
69 struct sockaddr *, struct route *);
70static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *);
71static int discioctl(struct ifnet *, u_long, caddr_t);
72static int disc_clone_create(struct if_clone *, int, caddr_t);
73static void disc_clone_destroy(struct ifnet *);
74
75static MALLOC_DEFINE(M_DISC, DISCNAME, "Discard interface");
76
77IFC_SIMPLE_DECLARE(disc, 0);
78
79static int
80disc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
81{
82 struct ifnet *ifp;
83 struct disc_softc *sc;
84
85 sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
86 ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
87 if (ifp == NULL) {
88 free(sc, M_DISC);
89 return (ENOSPC);
90 }
91
92 ifp->if_softc = sc;
93 if_initname(ifp, ifc->ifc_name, unit);
94 ifp->if_mtu = DSMTU;
95 /*
96 * IFF_LOOPBACK should not be removed from disc's flags because
97 * it controls what PF-specific routes are magically added when
98 * a network address is assigned to the interface. Things just
99 * won't work as intended w/o such routes because the output
100 * interface selection for a packet is totally route-driven.
101 * A valid alternative to IFF_LOOPBACK can be IFF_BROADCAST or

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

130}
131
132static int
133disc_modevent(module_t mod, int type, void *data)
134{
135
136 switch (type) {
137 case MOD_LOAD:
138 if_clone_attach(&disc_cloner);
139 break;
140 case MOD_UNLOAD:
141 if_clone_detach(&disc_cloner);
142 break;
143 default:
144 return (EOPNOTSUPP);
145 }
146 return (0);
147}
148
149static moduledata_t disc_mod = {

--- 96 unchanged lines hidden ---