xref: /freebsd/sys/net/if_loop.c (revision 44e33a075818146eb289c39c3ca2817f54517c9f)
1c398230bSWarner Losh /*-
2df8bae1dSRodney W. Grimes  * Copyright (c) 1982, 1986, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
7df8bae1dSRodney W. Grimes  * are met:
8df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
14df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
15df8bae1dSRodney W. Grimes  *    without specific prior written permission.
16df8bae1dSRodney W. Grimes  *
17df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
28df8bae1dSRodney W. Grimes  *
29fe6db7c7SRuslan Ermilov  *	@(#)if_loop.c	8.2 (Berkeley) 1/9/95
30c3aac50fSPeter Wemm  * $FreeBSD$
31df8bae1dSRodney W. Grimes  */
32df8bae1dSRodney W. Grimes 
33df8bae1dSRodney W. Grimes /*
34df8bae1dSRodney W. Grimes  * Loopback interface driver for protocol testing and timing.
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
377262d3e4SEivind Eklund #include "opt_atalk.h"
381d5e9e22SEivind Eklund #include "opt_inet.h"
39cfa1ca9dSYoshinobu Inoue #include "opt_inet6.h"
40430df5f4SEivind Eklund #include "opt_ipx.h"
41430df5f4SEivind Eklund 
42df8bae1dSRodney W. Grimes #include <sys/param.h>
43df8bae1dSRodney W. Grimes #include <sys/systm.h>
44df8bae1dSRodney W. Grimes #include <sys/kernel.h>
45df8bae1dSRodney W. Grimes #include <sys/mbuf.h>
462b120974SPeter Wemm #include <sys/module.h>
473d4ce33dSBrooks Davis #include <machine/bus.h>
483d4ce33dSBrooks Davis #include <sys/rman.h>
49df8bae1dSRodney W. Grimes #include <sys/socket.h>
5051a53488SBruce Evans #include <sys/sockio.h>
5190d9802fSPeter Wemm #include <sys/sysctl.h>
52603724d3SBjoern A. Zeeb #include <sys/vimage.h>
53df8bae1dSRodney W. Grimes 
54df8bae1dSRodney W. Grimes #include <net/if.h>
55f889d2efSBrooks Davis #include <net/if_clone.h>
56df8bae1dSRodney W. Grimes #include <net/if_types.h>
57df8bae1dSRodney W. Grimes #include <net/netisr.h>
58df8bae1dSRodney W. Grimes #include <net/route.h>
59df8bae1dSRodney W. Grimes #include <net/bpf.h>
60df8bae1dSRodney W. Grimes 
61df8bae1dSRodney W. Grimes #ifdef	INET
62df8bae1dSRodney W. Grimes #include <netinet/in.h>
63df8bae1dSRodney W. Grimes #include <netinet/in_var.h>
64df8bae1dSRodney W. Grimes #endif
65df8bae1dSRodney W. Grimes 
66cc6a66f2SJulian Elischer #ifdef IPX
67cc6a66f2SJulian Elischer #include <netipx/ipx.h>
68cc6a66f2SJulian Elischer #include <netipx/ipx_if.h>
69cc6a66f2SJulian Elischer #endif
70cc6a66f2SJulian Elischer 
7182cd038dSYoshinobu Inoue #ifdef INET6
7282cd038dSYoshinobu Inoue #ifndef INET
7382cd038dSYoshinobu Inoue #include <netinet/in.h>
7482cd038dSYoshinobu Inoue #endif
7582cd038dSYoshinobu Inoue #include <netinet6/in6_var.h>
76686cdd19SJun-ichiro itojun Hagino #include <netinet/ip6.h>
7782cd038dSYoshinobu Inoue #endif
7882cd038dSYoshinobu Inoue 
79655929bfSJulian Elischer #ifdef NETATALK
80655929bfSJulian Elischer #include <netatalk/at.h>
81655929bfSJulian Elischer #include <netatalk/at_var.h>
828cdfefbdSPeter Wemm #endif
83655929bfSJulian Elischer 
84db8889c6SDavid Greenman #ifdef TINY_LOMTU
85df8bae1dSRodney W. Grimes #define	LOMTU	(1024+512)
8682cd038dSYoshinobu Inoue #elif defined(LARGE_LOMTU)
8782cd038dSYoshinobu Inoue #define LOMTU	131072
88db8889c6SDavid Greenman #else
89af78195eSDavid Greenman #define LOMTU	16384
90db8889c6SDavid Greenman #endif
91df8bae1dSRodney W. Grimes 
923d4ce33dSBrooks Davis int		loioctl(struct ifnet *, u_long, caddr_t);
933d4ce33dSBrooks Davis static void	lortrequest(int, struct rtentry *, struct rt_addrinfo *);
943d4ce33dSBrooks Davis int		looutput(struct ifnet *ifp, struct mbuf *m,
953d4ce33dSBrooks Davis 		    struct sockaddr *dst, struct rtentry *rt);
966b7330e2SSam Leffler static int	lo_clone_create(struct if_clone *, int, caddr_t);
97bb2bfb4fSBrooks Davis static void	lo_clone_destroy(struct ifnet *);
983d4ce33dSBrooks Davis 
9944e33a07SMarko Zec #ifdef VIMAGE_GLOBALS
10044e33a07SMarko Zec struct ifnet *loif;			/* Used externally */
10144e33a07SMarko Zec #endif
1023d4ce33dSBrooks Davis 
103f889d2efSBrooks Davis IFC_SIMPLE_DECLARE(lo, 1);
1043d4ce33dSBrooks Davis 
105bb2bfb4fSBrooks Davis static void
10608304c16SRobert Watson lo_clone_destroy(struct ifnet *ifp)
1073d4ce33dSBrooks Davis {
1083d4ce33dSBrooks Davis 
109ae5a19beSBrooks Davis 	/* XXX: destroying lo0 will lead to panics. */
110603724d3SBjoern A. Zeeb 	KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
1113d4ce33dSBrooks Davis 
1123d4ce33dSBrooks Davis 	bpfdetach(ifp);
1133d4ce33dSBrooks Davis 	if_detach(ifp);
114fc74a9f9SBrooks Davis 	if_free(ifp);
1153d4ce33dSBrooks Davis }
1163d4ce33dSBrooks Davis 
117bb2bfb4fSBrooks Davis static int
11808304c16SRobert Watson lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
11990d9802fSPeter Wemm {
1208b615593SMarko Zec 	INIT_VNET_NET(curvnet);
121fc74a9f9SBrooks Davis 	struct ifnet *ifp;
12290d9802fSPeter Wemm 
1236db9940fSEd Schouten 	ifp = if_alloc(IFT_LOOP);
1246db9940fSEd Schouten 	if (ifp == NULL)
125fc74a9f9SBrooks Davis 		return (ENOSPC);
12690d9802fSPeter Wemm 
127fc74a9f9SBrooks Davis 	if_initname(ifp, ifc->ifc_name, unit);
128fc74a9f9SBrooks Davis 	ifp->if_mtu = LOMTU;
129fc74a9f9SBrooks Davis 	ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
130fc74a9f9SBrooks Davis 	ifp->if_ioctl = loioctl;
131fc74a9f9SBrooks Davis 	ifp->if_output = looutput;
132fc74a9f9SBrooks Davis 	ifp->if_snd.ifq_maxlen = ifqmaxlen;
133fc74a9f9SBrooks Davis 	if_attach(ifp);
13401399f34SDavid Malone 	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
135603724d3SBjoern A. Zeeb 	if (V_loif == NULL)
136603724d3SBjoern A. Zeeb 		V_loif = ifp;
1373b16e7b2SMaxime Henrion 
1383b16e7b2SMaxime Henrion 	return (0);
13990d9802fSPeter Wemm }
14090d9802fSPeter Wemm 
1412b120974SPeter Wemm static int
1422b120974SPeter Wemm loop_modevent(module_t mod, int type, void *data)
143df8bae1dSRodney W. Grimes {
14408304c16SRobert Watson 
1452b120974SPeter Wemm 	switch (type) {
1462b120974SPeter Wemm 	case MOD_LOAD:
14744e33a07SMarko Zec 		V_loif = NULL;
1483d4ce33dSBrooks Davis 		if_clone_attach(&lo_cloner);
1492b120974SPeter Wemm 		break;
15008304c16SRobert Watson 
1512b120974SPeter Wemm 	case MOD_UNLOAD:
1522b120974SPeter Wemm 		printf("loop module unload - not possible for this module type\n");
15308304c16SRobert Watson 		return (EINVAL);
15408304c16SRobert Watson 
1553e019deaSPoul-Henning Kamp 	default:
15608304c16SRobert Watson 		return (EOPNOTSUPP);
157f5fea3ddSPaul Traina 	}
15808304c16SRobert Watson 	return (0);
1592b120974SPeter Wemm }
1602b120974SPeter Wemm 
1612b120974SPeter Wemm static moduledata_t loop_mod = {
1622b120974SPeter Wemm 	"loop",
1632b120974SPeter Wemm 	loop_modevent,
1642b120974SPeter Wemm 	0
1652b120974SPeter Wemm };
1662b120974SPeter Wemm 
16778ece553SAlexander Kabaev DECLARE_MODULE(loop, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
168df8bae1dSRodney W. Grimes 
169cfa1ca9dSYoshinobu Inoue int
17008304c16SRobert Watson looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
17108304c16SRobert Watson     struct rtentry *rt)
172df8bae1dSRodney W. Grimes {
17301399f34SDavid Malone 	u_int32_t af;
17401399f34SDavid Malone 
175fe584538SDag-Erling Smørgrav 	M_ASSERTPKTHDR(m); /* check if we have the packet header */
176ed7509acSJulian Elischer 
177ed7509acSJulian Elischer 	if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
178ed7509acSJulian Elischer 		m_freem(m);
179ed7509acSJulian Elischer 		return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
180ed7509acSJulian Elischer 		        rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
181ed7509acSJulian Elischer 	}
18282cd038dSYoshinobu Inoue 
183ed7509acSJulian Elischer 	ifp->if_opackets++;
184ed7509acSJulian Elischer 	ifp->if_obytes += m->m_pkthdr.len;
18501399f34SDavid Malone 
18601399f34SDavid Malone 	/* BPF writes need to be handled specially. */
18701399f34SDavid Malone 	if (dst->sa_family == AF_UNSPEC) {
18801399f34SDavid Malone 		bcopy(dst->sa_data, &af, sizeof(af));
18901399f34SDavid Malone 		dst->sa_family = af;
19001399f34SDavid Malone 	}
19101399f34SDavid Malone 
192201c2527SJulian Elischer #if 1	/* XXX */
193201c2527SJulian Elischer 	switch (dst->sa_family) {
194201c2527SJulian Elischer 	case AF_INET:
19582cd038dSYoshinobu Inoue 	case AF_INET6:
196201c2527SJulian Elischer 	case AF_IPX:
197201c2527SJulian Elischer 	case AF_APPLETALK:
19805b3ccefSJulian Elischer 		break;
199201c2527SJulian Elischer 	default:
20071582bf5SRobert Watson 		printf("looutput: af=%d unexpected\n", dst->sa_family);
201201c2527SJulian Elischer 		m_freem(m);
202201c2527SJulian Elischer 		return (EAFNOSUPPORT);
203201c2527SJulian Elischer 	}
204201c2527SJulian Elischer #endif
20506a429a3SArchie Cobbs 	return (if_simloop(ifp, m, dst->sa_family, 0));
206ed7509acSJulian Elischer }
207ed7509acSJulian Elischer 
208ed7509acSJulian Elischer /*
209ed7509acSJulian Elischer  * if_simloop()
210ed7509acSJulian Elischer  *
211ed7509acSJulian Elischer  * This function is to support software emulation of hardware loopback,
212ed7509acSJulian Elischer  * i.e., for interfaces with the IFF_SIMPLEX attribute. Since they can't
213ed7509acSJulian Elischer  * hear their own broadcasts, we create a copy of the packet that we
214ed7509acSJulian Elischer  * would normally receive via a hardware loopback.
215ed7509acSJulian Elischer  *
216ed7509acSJulian Elischer  * This function expects the packet to include the media header of length hlen.
217ed7509acSJulian Elischer  */
218ed7509acSJulian Elischer int
21908304c16SRobert Watson if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen)
220ed7509acSJulian Elischer {
2218b615593SMarko Zec 	INIT_VNET_NET(ifp->if_vnet);
222df5e1987SJonathan Lemon 	int isr;
223df8bae1dSRodney W. Grimes 
224fe584538SDag-Erling Smørgrav 	M_ASSERTPKTHDR(m);
2259c855a36SSam Leffler 	m_tag_delete_nonpersistent(m);
226ed7509acSJulian Elischer 	m->m_pkthdr.rcvif = ifp;
22706a429a3SArchie Cobbs 
2288343821bSSUZUKI Shinsuke 	/*
2298343821bSSUZUKI Shinsuke 	 * Let BPF see incoming packet in the following manner:
2308343821bSSUZUKI Shinsuke 	 *  - Emulated packet loopback for a simplex interface
2318343821bSSUZUKI Shinsuke 	 *    (net/if_ethersubr.c)
2328343821bSSUZUKI Shinsuke 	 *	-> passes it to ifp's BPF
2338343821bSSUZUKI Shinsuke 	 *  - IPv4/v6 multicast packet loopback (netinet(6)/ip(6)_output.c)
2348343821bSSUZUKI Shinsuke 	 *	-> not passes it to any BPF
2358343821bSSUZUKI Shinsuke 	 *  - Normal packet loopback from myself to myself (net/if_loop.c)
2368343821bSSUZUKI Shinsuke 	 *	-> passes to lo0's BPF (even in case of IPv6, where ifp!=lo0)
2378343821bSSUZUKI Shinsuke 	 */
2388343821bSSUZUKI Shinsuke 	if (hlen > 0) {
23916d878ccSChristian S.J. Peron 		if (bpf_peers_present(ifp->if_bpf)) {
2408343821bSSUZUKI Shinsuke 			bpf_mtap(ifp->if_bpf, m);
2418343821bSSUZUKI Shinsuke 		}
2428343821bSSUZUKI Shinsuke 	} else {
243603724d3SBjoern A. Zeeb 		if (bpf_peers_present(V_loif->if_bpf)) {
244603724d3SBjoern A. Zeeb 			if ((m->m_flags & M_MCAST) == 0 || V_loif == ifp) {
2458343821bSSUZUKI Shinsuke 				/* XXX beware sizeof(af) != 4 */
2468343821bSSUZUKI Shinsuke 				u_int32_t af1 = af;
2478343821bSSUZUKI Shinsuke 
248df8bae1dSRodney W. Grimes 				/*
249437ffe18SSam Leffler 				 * We need to prepend the address family.
250df8bae1dSRodney W. Grimes 				 */
251603724d3SBjoern A. Zeeb 				bpf_mtap2(V_loif->if_bpf, &af1, sizeof(af1), m);
2528343821bSSUZUKI Shinsuke 			}
2538343821bSSUZUKI Shinsuke 		}
254df8bae1dSRodney W. Grimes 	}
255df8bae1dSRodney W. Grimes 
256ed7509acSJulian Elischer 	/* Strip away media header */
2573a43ad8fSDoug Rabson 	if (hlen > 0) {
258fe81f64fSAndrew Gallatin 		m_adj(m, hlen);
259f6966ecdSOlivier Houchard #ifndef __NO_STRICT_ALIGNMENT
26073dbd3daSJohn Baldwin 		/*
26173dbd3daSJohn Baldwin 		 * Some archs do not like unaligned data, so
26273dbd3daSJohn Baldwin 		 * we move data down in the first mbuf.
26373dbd3daSJohn Baldwin 		 */
264fe81f64fSAndrew Gallatin 		if (mtod(m, vm_offset_t) & 3) {
26560ed92ddSMatt Jacob 			KASSERT(hlen >= 3, ("if_simloop: hlen too small"));
266fe81f64fSAndrew Gallatin 			bcopy(m->m_data,
267fe81f64fSAndrew Gallatin 			    (char *)(mtod(m, vm_offset_t)
268fe81f64fSAndrew Gallatin 				- (mtod(m, vm_offset_t) & 3)),
269fe81f64fSAndrew Gallatin 			    m->m_len);
270445e045bSAlexander Kabaev 			m->m_data -= (mtod(m,vm_offset_t) & 3);
271fe81f64fSAndrew Gallatin 		}
2723a43ad8fSDoug Rabson #endif
2733a43ad8fSDoug Rabson 	}
274ed7509acSJulian Elischer 
27506a429a3SArchie Cobbs 	/* Deliver to upper layer protocol */
27606a429a3SArchie Cobbs 	switch (af) {
277df8bae1dSRodney W. Grimes #ifdef INET
278df8bae1dSRodney W. Grimes 	case AF_INET:
279df8bae1dSRodney W. Grimes 		isr = NETISR_IP;
280df8bae1dSRodney W. Grimes 		break;
281df8bae1dSRodney W. Grimes #endif
28282cd038dSYoshinobu Inoue #ifdef INET6
28382cd038dSYoshinobu Inoue 	case AF_INET6:
28482cd038dSYoshinobu Inoue 		m->m_flags |= M_LOOP;
28582cd038dSYoshinobu Inoue 		isr = NETISR_IPV6;
28682cd038dSYoshinobu Inoue 		break;
28782cd038dSYoshinobu Inoue #endif
288cc6a66f2SJulian Elischer #ifdef IPX
289cc6a66f2SJulian Elischer 	case AF_IPX:
290cc6a66f2SJulian Elischer 		isr = NETISR_IPX;
291cc6a66f2SJulian Elischer 		break;
292cc6a66f2SJulian Elischer #endif
293655929bfSJulian Elischer #ifdef NETATALK
294655929bfSJulian Elischer 	case AF_APPLETALK:
2951cafed39SJonathan Lemon 		isr = NETISR_ATALK2;
296655929bfSJulian Elischer 		break;
2978cdfefbdSPeter Wemm #endif
298df8bae1dSRodney W. Grimes 	default:
29906a429a3SArchie Cobbs 		printf("if_simloop: can't handle af=%d\n", af);
300df8bae1dSRodney W. Grimes 		m_freem(m);
301df8bae1dSRodney W. Grimes 		return (EAFNOSUPPORT);
302df8bae1dSRodney W. Grimes 	}
303df8bae1dSRodney W. Grimes 	ifp->if_ipackets++;
304df8bae1dSRodney W. Grimes 	ifp->if_ibytes += m->m_pkthdr.len;
3053161f583SAndre Oppermann 	netisr_queue(isr, m);	/* mbuf is free'd on failure. */
306df8bae1dSRodney W. Grimes 	return (0);
307df8bae1dSRodney W. Grimes }
308df8bae1dSRodney W. Grimes 
309df8bae1dSRodney W. Grimes /* ARGSUSED */
3103bda9f9bSPoul-Henning Kamp static void
31108304c16SRobert Watson lortrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
312df8bae1dSRodney W. Grimes {
31308304c16SRobert Watson 
314d1dd20beSSam Leffler 	RT_LOCK_ASSERT(rt);
31597d8d152SAndre Oppermann 	rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu;
316df8bae1dSRodney W. Grimes }
317df8bae1dSRodney W. Grimes 
318df8bae1dSRodney W. Grimes /*
319df8bae1dSRodney W. Grimes  * Process an ioctl request.
320df8bae1dSRodney W. Grimes  */
321df8bae1dSRodney W. Grimes /* ARGSUSED */
322cfa1ca9dSYoshinobu Inoue int
32308304c16SRobert Watson loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
324df8bae1dSRodney W. Grimes {
32508304c16SRobert Watson 	struct ifaddr *ifa;
32608304c16SRobert Watson 	struct ifreq *ifr = (struct ifreq *)data;
32708304c16SRobert Watson 	int error = 0;
328df8bae1dSRodney W. Grimes 
329df8bae1dSRodney W. Grimes 	switch (cmd) {
330df8bae1dSRodney W. Grimes 	case SIOCSIFADDR:
33113f4c340SRobert Watson 		ifp->if_flags |= IFF_UP;
33213f4c340SRobert Watson 		ifp->if_drv_flags |= IFF_DRV_RUNNING;
333df8bae1dSRodney W. Grimes 		ifa = (struct ifaddr *)data;
334df8bae1dSRodney W. Grimes 		ifa->ifa_rtrequest = lortrequest;
335df8bae1dSRodney W. Grimes 		/*
336df8bae1dSRodney W. Grimes 		 * Everything else is done at a higher level.
337df8bae1dSRodney W. Grimes 		 */
338df8bae1dSRodney W. Grimes 		break;
339df8bae1dSRodney W. Grimes 
340df8bae1dSRodney W. Grimes 	case SIOCADDMULTI:
341df8bae1dSRodney W. Grimes 	case SIOCDELMULTI:
342df8bae1dSRodney W. Grimes 		if (ifr == 0) {
343df8bae1dSRodney W. Grimes 			error = EAFNOSUPPORT;		/* XXX */
344df8bae1dSRodney W. Grimes 			break;
345df8bae1dSRodney W. Grimes 		}
346df8bae1dSRodney W. Grimes 		switch (ifr->ifr_addr.sa_family) {
347df8bae1dSRodney W. Grimes 
348df8bae1dSRodney W. Grimes #ifdef INET
349df8bae1dSRodney W. Grimes 		case AF_INET:
350df8bae1dSRodney W. Grimes 			break;
351df8bae1dSRodney W. Grimes #endif
35282cd038dSYoshinobu Inoue #ifdef INET6
35382cd038dSYoshinobu Inoue 		case AF_INET6:
35482cd038dSYoshinobu Inoue 			break;
35582cd038dSYoshinobu Inoue #endif
356df8bae1dSRodney W. Grimes 
357df8bae1dSRodney W. Grimes 		default:
358df8bae1dSRodney W. Grimes 			error = EAFNOSUPPORT;
359df8bae1dSRodney W. Grimes 			break;
360df8bae1dSRodney W. Grimes 		}
361df8bae1dSRodney W. Grimes 		break;
362df8bae1dSRodney W. Grimes 
36390fd8c38SDavid Greenman 	case SIOCSIFMTU:
36490fd8c38SDavid Greenman 		ifp->if_mtu = ifr->ifr_mtu;
36590fd8c38SDavid Greenman 		break;
36690fd8c38SDavid Greenman 
367ce42f1fbSPoul-Henning Kamp 	case SIOCSIFFLAGS:
368ce42f1fbSPoul-Henning Kamp 		break;
369ce42f1fbSPoul-Henning Kamp 
370df8bae1dSRodney W. Grimes 	default:
371df8bae1dSRodney W. Grimes 		error = EINVAL;
372df8bae1dSRodney W. Grimes 	}
373df8bae1dSRodney W. Grimes 	return (error);
374df8bae1dSRodney W. Grimes }
375