1159965Sthompsa/*-
2159965Sthompsa * Copyright (c) 2006 The FreeBSD Project.
3291292Sae * Copyright (c) 2015 Andrey V. Elsukov <ae@FreeBSD.org>
4159965Sthompsa * All rights reserved.
5159965Sthompsa *
6159965Sthompsa * Redistribution and use in source and binary forms, with or without
7159965Sthompsa * modification, are permitted provided that the following conditions
8159965Sthompsa * are met:
9159965Sthompsa *
10159965Sthompsa * 1. Redistributions of source code must retain the above copyright
11159965Sthompsa *    notice, this list of conditions and the following disclaimer.
12159965Sthompsa * 2. Redistributions in binary form must reproduce the above copyright
13159965Sthompsa *    notice, this list of conditions and the following disclaimer in the
14159965Sthompsa *    documentation and/or other materials provided with the distribution.
15159965Sthompsa *
16159965Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17159965Sthompsa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18159965Sthompsa * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19159965Sthompsa * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20159965Sthompsa * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21159965Sthompsa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22159965Sthompsa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23159965Sthompsa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24159965Sthompsa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25159965Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26159965Sthompsa * SUCH DAMAGE.
27159965Sthompsa *
28159965Sthompsa * $FreeBSD: stable/11/sys/net/if_enc.c 365277 2020-09-02 20:36:33Z jhb $
29159965Sthompsa */
30159965Sthompsa
31221130Sbz#include "opt_inet.h"
32221130Sbz#include "opt_inet6.h"
33365277Sjhb#include "opt_ipsec.h"
34221130Sbz
35159965Sthompsa#include <sys/param.h>
36159965Sthompsa#include <sys/systm.h>
37291335Sngie#include <sys/hhook.h>
38159965Sthompsa#include <sys/kernel.h>
39159965Sthompsa#include <sys/malloc.h>
40159965Sthompsa#include <sys/mbuf.h>
41159965Sthompsa#include <sys/module.h>
42159965Sthompsa#include <machine/bus.h>
43159965Sthompsa#include <sys/rman.h>
44159965Sthompsa#include <sys/socket.h>
45159965Sthompsa#include <sys/sockio.h>
46159965Sthompsa#include <sys/sysctl.h>
47159965Sthompsa
48159965Sthompsa#include <net/if.h>
49291335Sngie#include <net/if_enc.h>
50257176Sglebius#include <net/if_var.h>
51159965Sthompsa#include <net/if_clone.h>
52159965Sthompsa#include <net/if_types.h>
53159965Sthompsa#include <net/pfil.h>
54159965Sthompsa#include <net/route.h>
55159965Sthompsa#include <net/netisr.h>
56159965Sthompsa#include <net/bpf.h>
57195699Srwatson#include <net/vnet.h>
58159965Sthompsa
59159965Sthompsa#include <netinet/in.h>
60159965Sthompsa#include <netinet/in_systm.h>
61159965Sthompsa#include <netinet/ip.h>
62159965Sthompsa#include <netinet/ip_var.h>
63159965Sthompsa#include <netinet/in_var.h>
64159965Sthompsa
65159965Sthompsa#ifdef INET6
66159965Sthompsa#include <netinet/ip6.h>
67159965Sthompsa#include <netinet6/ip6_var.h>
68159965Sthompsa#endif
69159965Sthompsa
70159965Sthompsa#include <netipsec/ipsec.h>
71174054Sbz#include <netipsec/xform.h>
72159965Sthompsa
73159965Sthompsa#define ENCMTU		(1024+512)
74159965Sthompsa
75159965Sthompsa/* XXX this define must have the same value as in OpenBSD */
76159965Sthompsa#define M_CONF		0x0400	/* payload was encrypted (ESP-transport) */
77159965Sthompsa#define M_AUTH		0x0800	/* payload was authenticated (AH or ESP auth) */
78159965Sthompsa#define M_AUTH_AH	0x2000	/* header was authenticated (AH) */
79159965Sthompsa
80159965Sthompsastruct enchdr {
81159965Sthompsa	u_int32_t af;
82159965Sthompsa	u_int32_t spi;
83159965Sthompsa	u_int32_t flags;
84159965Sthompsa};
85159965Sthompsastruct enc_softc {
86159965Sthompsa	struct	ifnet *sc_ifp;
87159965Sthompsa};
88291292Saestatic VNET_DEFINE(struct enc_softc *, enc_sc);
89291292Sae#define	V_enc_sc	VNET(enc_sc)
90291292Saestatic VNET_DEFINE(struct if_clone *, enc_cloner);
91291292Sae#define	V_enc_cloner	VNET(enc_cloner)
92159965Sthompsa
93159965Sthompsastatic int	enc_ioctl(struct ifnet *, u_long, caddr_t);
94291292Saestatic int	enc_output(struct ifnet *, struct mbuf *,
95291292Sae    const struct sockaddr *, struct route *);
96160233Sthompsastatic int	enc_clone_create(struct if_clone *, int, caddr_t);
97160099Sthompsastatic void	enc_clone_destroy(struct ifnet *);
98291292Saestatic int	enc_add_hhooks(struct enc_softc *);
99291292Saestatic void	enc_remove_hhooks(struct enc_softc *);
100291292Sae
101241610Sglebiusstatic const char encname[] = "enc";
102159965Sthompsa
103322808Sae#define	IPSEC_ENC_AFTER_PFIL	0x04
104174054Sbz/*
105174054Sbz * Before and after are relative to when we are stripping the
106174054Sbz * outer IP header.
107322808Sae *
108322808Sae * AFTER_PFIL flag used only for bpf_mask_*. It enables BPF capturing
109322808Sae * after PFIL hook execution. It might be useful when PFIL hook does
110322808Sae * some changes to the packet, e.g. address translation. If PFIL hook
111322808Sae * consumes mbuf, nothing will be captured.
112174054Sbz */
113291292Saestatic VNET_DEFINE(int, filter_mask_in) = IPSEC_ENC_BEFORE;
114291292Saestatic VNET_DEFINE(int, bpf_mask_in) = IPSEC_ENC_BEFORE;
115291292Saestatic VNET_DEFINE(int, filter_mask_out) = IPSEC_ENC_BEFORE;
116291292Saestatic VNET_DEFINE(int, bpf_mask_out) = IPSEC_ENC_BEFORE | IPSEC_ENC_AFTER;
117291292Sae#define	V_filter_mask_in	VNET(filter_mask_in)
118291292Sae#define	V_bpf_mask_in		VNET(bpf_mask_in)
119291292Sae#define	V_filter_mask_out	VNET(filter_mask_out)
120291292Sae#define	V_bpf_mask_out		VNET(bpf_mask_out)
121291292Sae
122227309Sedstatic SYSCTL_NODE(_net, OID_AUTO, enc, CTLFLAG_RW, 0, "enc sysctl");
123227309Sedstatic SYSCTL_NODE(_net_enc, OID_AUTO, in, CTLFLAG_RW, 0, "enc input sysctl");
124227309Sedstatic SYSCTL_NODE(_net_enc, OID_AUTO, out, CTLFLAG_RW, 0, "enc output sysctl");
125291292SaeSYSCTL_INT(_net_enc_in, OID_AUTO, ipsec_filter_mask,
126291292Sae    CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(filter_mask_in), 0,
127291292Sae    "IPsec input firewall filter mask");
128291292SaeSYSCTL_INT(_net_enc_in, OID_AUTO, ipsec_bpf_mask,
129291292Sae    CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(bpf_mask_in), 0,
130291292Sae    "IPsec input bpf mask");
131291292SaeSYSCTL_INT(_net_enc_out, OID_AUTO, ipsec_filter_mask,
132291292Sae    CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(filter_mask_out), 0,
133291292Sae    "IPsec output firewall filter mask");
134291292SaeSYSCTL_INT(_net_enc_out, OID_AUTO, ipsec_bpf_mask,
135291292Sae    CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(bpf_mask_out), 0,
136291292Sae    "IPsec output bpf mask");
137174054Sbz
138160099Sthompsastatic void
139159965Sthompsaenc_clone_destroy(struct ifnet *ifp)
140159965Sthompsa{
141291292Sae	struct enc_softc *sc;
142159965Sthompsa
143291292Sae	sc = ifp->if_softc;
144291292Sae	KASSERT(sc == V_enc_sc, ("sc != ifp->if_softc"));
145291292Sae
146159965Sthompsa	bpfdetach(ifp);
147159965Sthompsa	if_detach(ifp);
148159965Sthompsa	if_free(ifp);
149291292Sae	free(sc, M_DEVBUF);
150291292Sae	V_enc_sc = NULL;
151159965Sthompsa}
152159965Sthompsa
153159965Sthompsastatic int
154160233Sthompsaenc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
155159965Sthompsa{
156159965Sthompsa	struct ifnet *ifp;
157159965Sthompsa	struct enc_softc *sc;
158159965Sthompsa
159291292Sae	sc = malloc(sizeof(struct enc_softc), M_DEVBUF,
160291292Sae	    M_WAITOK | M_ZERO);
161159965Sthompsa	ifp = sc->sc_ifp = if_alloc(IFT_ENC);
162159965Sthompsa	if (ifp == NULL) {
163159965Sthompsa		free(sc, M_DEVBUF);
164159965Sthompsa		return (ENOSPC);
165159965Sthompsa	}
166291292Sae	if (V_enc_sc != NULL) {
167291292Sae		if_free(ifp);
168291292Sae		free(sc, M_DEVBUF);
169291292Sae		return (EEXIST);
170291292Sae	}
171291292Sae	V_enc_sc = sc;
172241610Sglebius	if_initname(ifp, encname, unit);
173159965Sthompsa	ifp->if_mtu = ENCMTU;
174159965Sthompsa	ifp->if_ioctl = enc_ioctl;
175159965Sthompsa	ifp->if_output = enc_output;
176159965Sthompsa	ifp->if_softc = sc;
177159965Sthompsa	if_attach(ifp);
178159969Sthompsa	bpfattach(ifp, DLT_ENC, sizeof(struct enchdr));
179159965Sthompsa	return (0);
180159965Sthompsa}
181159965Sthompsa
182159965Sthompsastatic int
183291292Saeenc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
184291292Sae    struct route *ro)
185159965Sthompsa{
186291292Sae
187291292Sae	m_freem(m);
188159965Sthompsa	return (0);
189159965Sthompsa}
190159965Sthompsa
191159965Sthompsastatic int
192291292Saeenc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
193159965Sthompsa{
194291292Sae
195291292Sae	if (cmd != SIOCSIFFLAGS)
196291292Sae		return (EINVAL);
197291292Sae	if (ifp->if_flags & IFF_UP)
198291292Sae		ifp->if_drv_flags |= IFF_DRV_RUNNING;
199291292Sae	else
200291292Sae		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
201159965Sthompsa	return (0);
202159965Sthompsa}
203159965Sthompsa
204322808Saestatic void
205322808Saeenc_bpftap(struct ifnet *ifp, struct mbuf *m, const struct secasvar *sav,
206322808Sae    int32_t hhook_type, uint8_t enc, uint8_t af)
207322808Sae{
208322808Sae	struct enchdr hdr;
209322808Sae
210322808Sae	if (hhook_type == HHOOK_TYPE_IPSEC_IN &&
211322808Sae	    (enc & V_bpf_mask_in) == 0)
212322808Sae		return;
213322808Sae	else if (hhook_type == HHOOK_TYPE_IPSEC_OUT &&
214322808Sae	    (enc & V_bpf_mask_out) == 0)
215322808Sae		return;
216322808Sae	if (bpf_peers_present(ifp->if_bpf) == 0)
217322808Sae		return;
218322808Sae	hdr.af = af;
219322808Sae	hdr.spi = sav->spi;
220322808Sae	hdr.flags = 0;
221322808Sae	if (sav->alg_enc != SADB_EALG_NONE)
222322808Sae		hdr.flags |= M_CONF;
223322808Sae	if (sav->alg_auth != SADB_AALG_NONE)
224322808Sae		hdr.flags |= M_AUTH;
225322808Sae	bpf_mtap2(ifp->if_bpf, &hdr, sizeof(hdr), m);
226322808Sae}
227322808Sae
228159965Sthompsa/*
229291292Sae * One helper hook function is used by any hook points.
230291292Sae * + from hhook_type we can determine the packet direction:
231291292Sae *   HHOOK_TYPE_IPSEC_IN or HHOOK_TYPE_IPSEC_OUT;
232291292Sae * + from hhook_id we can determine address family: AF_INET or AF_INET6;
233291292Sae * + udata contains pointer to enc_softc;
234291292Sae * + ctx_data contains pointer to struct ipsec_ctx_data.
235159965Sthompsa */
236159965Sthompsastatic int
237291292Saeenc_hhook(int32_t hhook_type, int32_t hhook_id, void *udata, void *ctx_data,
238291292Sae    void *hdata, struct osd *hosd)
239159965Sthompsa{
240291292Sae	struct ipsec_ctx_data *ctx;
241291292Sae	struct enc_softc *sc;
242291292Sae	struct ifnet *ifp, *rcvif;
243291292Sae	struct pfil_head *ph;
244291292Sae	int pdir;
245159965Sthompsa
246291292Sae	sc = (struct enc_softc *)udata;
247291292Sae	ifp = sc->sc_ifp;
248291292Sae	if ((ifp->if_flags & IFF_UP) == 0)
249291292Sae		return (0);
250160011Sthompsa
251291292Sae	ctx = (struct ipsec_ctx_data *)ctx_data;
252291292Sae	/* XXX: wrong hook point was used by caller? */
253291292Sae	if (ctx->af != hhook_id)
254291292Sae		return (EPFNOSUPPORT);
255159965Sthompsa
256322808Sae	enc_bpftap(ifp, *ctx->mp, ctx->sav, hhook_type, ctx->enc, ctx->af);
257291292Sae	switch (hhook_type) {
258291292Sae	case HHOOK_TYPE_IPSEC_IN:
259291292Sae		if (ctx->enc == IPSEC_ENC_BEFORE) {
260291292Sae			/* Do accounting only once */
261291292Sae			if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
262291292Sae			if_inc_counter(ifp, IFCOUNTER_IBYTES,
263291292Sae			    (*ctx->mp)->m_pkthdr.len);
264291292Sae		}
265291292Sae		if ((ctx->enc & V_filter_mask_in) == 0)
266291292Sae			return (0); /* skip pfil processing */
267291292Sae		pdir = PFIL_IN;
268159965Sthompsa		break;
269291292Sae	case HHOOK_TYPE_IPSEC_OUT:
270291292Sae		if (ctx->enc == IPSEC_ENC_BEFORE) {
271291292Sae			/* Do accounting only once */
272291292Sae			if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
273291292Sae			if_inc_counter(ifp, IFCOUNTER_OBYTES,
274291292Sae			    (*ctx->mp)->m_pkthdr.len);
275291292Sae		}
276291292Sae		if ((ctx->enc & V_filter_mask_out) == 0)
277291292Sae			return (0); /* skip pfil processing */
278291292Sae		pdir = PFIL_OUT;
279291292Sae		break;
280291292Sae	default:
281291292Sae		return (EINVAL);
282291292Sae	}
283159965Sthompsa
284291292Sae	switch (hhook_id) {
285291292Sae#ifdef INET
286291292Sae	case AF_INET:
287291292Sae		ph = &V_inet_pfil_hook;
288291292Sae		break;
289291292Sae#endif
290291292Sae#ifdef INET6
291291292Sae	case AF_INET6:
292291292Sae		ph = &V_inet6_pfil_hook;
293291292Sae		break;
294291292Sae#endif
295159965Sthompsa	default:
296291292Sae		ph = NULL;
297159965Sthompsa	}
298291292Sae	if (ph == NULL || !PFIL_HOOKED(ph))
299291292Sae		return (0);
300291292Sae	/* Make a packet looks like it was received on enc(4) */
301291292Sae	rcvif = (*ctx->mp)->m_pkthdr.rcvif;
302291292Sae	(*ctx->mp)->m_pkthdr.rcvif = ifp;
303332513Skp	if (pfil_run_hooks(ph, ctx->mp, ifp, pdir, 0, ctx->inp) != 0 ||
304291292Sae	    *ctx->mp == NULL) {
305291292Sae		*ctx->mp = NULL; /* consumed by filter */
306291292Sae		return (EACCES);
307291292Sae	}
308291292Sae	(*ctx->mp)->m_pkthdr.rcvif = rcvif;
309322808Sae	enc_bpftap(ifp, *ctx->mp, ctx->sav, hhook_type,
310322808Sae	    IPSEC_ENC_AFTER_PFIL, ctx->af);
311291292Sae	return (0);
312159965Sthompsa}
313159965Sthompsa
314291292Saestatic int
315291292Saeenc_add_hhooks(struct enc_softc *sc)
316159965Sthompsa{
317291292Sae	struct hookinfo hki;
318291292Sae	int error;
319159965Sthompsa
320291292Sae	error = EPFNOSUPPORT;
321291292Sae	hki.hook_func = enc_hhook;
322291292Sae	hki.hook_helper = NULL;
323291292Sae	hki.hook_udata = sc;
324221130Sbz#ifdef INET
325291292Sae	hki.hook_id = AF_INET;
326291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_IN;
327291292Sae	error = hhook_add_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET],
328291292Sae	    &hki, HHOOK_WAITOK);
329291292Sae	if (error != 0)
330291292Sae		return (error);
331291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_OUT;
332291292Sae	error = hhook_add_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET],
333291292Sae	    &hki, HHOOK_WAITOK);
334291292Sae	if (error != 0)
335291292Sae		return (error);
336221130Sbz#endif
337159965Sthompsa#ifdef INET6
338291292Sae	hki.hook_id = AF_INET6;
339291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_IN;
340291292Sae	error = hhook_add_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET6],
341291292Sae	    &hki, HHOOK_WAITOK);
342291292Sae	if (error != 0)
343291292Sae		return (error);
344291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_OUT;
345291292Sae	error = hhook_add_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET6],
346291292Sae	    &hki, HHOOK_WAITOK);
347291292Sae	if (error != 0)
348291292Sae		return (error);
349159965Sthompsa#endif
350291292Sae	return (error);
351291292Sae}
352159965Sthompsa
353291292Saestatic void
354291292Saeenc_remove_hhooks(struct enc_softc *sc)
355291292Sae{
356291292Sae	struct hookinfo hki;
357159965Sthompsa
358291292Sae	hki.hook_func = enc_hhook;
359291292Sae	hki.hook_helper = NULL;
360291292Sae	hki.hook_udata = sc;
361221130Sbz#ifdef INET
362291292Sae	hki.hook_id = AF_INET;
363291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_IN;
364291292Sae	hhook_remove_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET], &hki);
365291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_OUT;
366291292Sae	hhook_remove_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET], &hki);
367221130Sbz#endif
368159965Sthompsa#ifdef INET6
369291292Sae	hki.hook_id = AF_INET6;
370291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_IN;
371291292Sae	hhook_remove_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET6], &hki);
372291292Sae	hki.hook_type = HHOOK_TYPE_IPSEC_OUT;
373291292Sae	hhook_remove_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET6], &hki);
374159965Sthompsa#endif
375291292Sae}
376159965Sthompsa
377291292Saestatic void
378291292Saevnet_enc_init(const void *unused __unused)
379291292Sae{
380159965Sthompsa
381291292Sae	V_enc_sc = NULL;
382291292Sae	V_enc_cloner = if_clone_simple(encname, enc_clone_create,
383291292Sae	    enc_clone_destroy, 1);
384159965Sthompsa}
385302054SbzVNET_SYSINIT(vnet_enc_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
386291292Sae    vnet_enc_init, NULL);
387159965Sthompsa
388291292Saestatic void
389302054Sbzvnet_enc_init_proto(void *unused __unused)
390302054Sbz{
391302054Sbz	KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc));
392302054Sbz
393302054Sbz	if (enc_add_hhooks(V_enc_sc) != 0)
394302054Sbz		enc_clone_destroy(V_enc_sc->sc_ifp);
395302054Sbz}
396302054SbzVNET_SYSINIT(vnet_enc_init_proto, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
397302054Sbz    vnet_enc_init_proto, NULL);
398302054Sbz
399302054Sbzstatic void
400291292Saevnet_enc_uninit(const void *unused __unused)
401159965Sthompsa{
402302054Sbz	KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc));
403159965Sthompsa
404291292Sae	if_clone_detach(V_enc_cloner);
405291292Sae}
406302054SbzVNET_SYSUNINIT(vnet_enc_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY,
407291292Sae    vnet_enc_uninit, NULL);
408159965Sthompsa
409302054Sbz/*
410302054Sbz * The hhook consumer needs to go before ip[6]_destroy are called on
411302054Sbz * SI_ORDER_THIRD.
412302054Sbz */
413302054Sbzstatic void
414302054Sbzvnet_enc_uninit_hhook(const void *unused __unused)
415302054Sbz{
416302054Sbz	KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc));
417302054Sbz
418302054Sbz	enc_remove_hhooks(V_enc_sc);
419302054Sbz}
420302054SbzVNET_SYSUNINIT(vnet_enc_uninit_hhook, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH,
421302054Sbz    vnet_enc_uninit_hhook, NULL);
422302054Sbz
423291292Saestatic int
424291292Saeenc_modevent(module_t mod, int type, void *data)
425291292Sae{
426159965Sthompsa
427291292Sae	switch (type) {
428291292Sae	case MOD_LOAD:
429291292Sae	case MOD_UNLOAD:
430291292Sae		break;
431291292Sae	default:
432291292Sae		return (EOPNOTSUPP);
433174054Sbz	}
434291292Sae	return (0);
435291292Sae}
436174054Sbz
437291292Saestatic moduledata_t enc_mod = {
438291292Sae	"if_enc",
439291292Sae	enc_modevent,
440291292Sae	0
441291292Sae};
442159965Sthompsa
443302054SbzDECLARE_MODULE(if_enc, enc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
444316457SaeMODULE_VERSION(if_enc, 1);
445