Deleted Added
full compact
if_disc.c (191148) if_disc.c (241610)
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
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 $
30 * $FreeBSD: head/sys/net/if_disc.c 241610 2012-10-16 13:37:54Z glebius $
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
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
62struct disc_softc {
63 struct ifnet *sc_ifp;
64};
65
66static int discoutput(struct ifnet *, struct mbuf *,
67 struct sockaddr *, struct route *);
68static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *);
69static int discioctl(struct ifnet *, u_long, caddr_t);
70static int disc_clone_create(struct if_clone *, int, caddr_t);
71static void disc_clone_destroy(struct ifnet *);
72
75static MALLOC_DEFINE(M_DISC, DISCNAME, "Discard interface");
73static const char discname[] = "disc";
74static MALLOC_DEFINE(M_DISC, discname, "Discard interface");
76
75
77IFC_SIMPLE_DECLARE(disc, 0);
76static struct if_clone *disc_cloner;
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;
77
78static int
79disc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
80{
81 struct ifnet *ifp;
82 struct disc_softc *sc;
83
84 sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
85 ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
86 if (ifp == NULL) {
87 free(sc, M_DISC);
88 return (ENOSPC);
89 }
90
91 ifp->if_softc = sc;
93 if_initname(ifp, ifc->ifc_name, unit);
92 if_initname(ifp, discname, 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:
93 ifp->if_mtu = DSMTU;
94 /*
95 * IFF_LOOPBACK should not be removed from disc's flags because
96 * it controls what PF-specific routes are magically added when
97 * a network address is assigned to the interface. Things just
98 * won't work as intended w/o such routes because the output
99 * interface selection for a packet is totally route-driven.
100 * A valid alternative to IFF_LOOPBACK can be IFF_BROADCAST or

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

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

--- 96 unchanged lines hidden ---