xref: /freebsd/sys/net/if_loop.c (revision 97021c246444967a8f441a90076fb4f7ef22fb3a)
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 {
10897021c24SMarko Zec #ifdef INVARIANTS
10997021c24SMarko Zec 	INIT_VNET_NET(ifp->if_vnet);
11097021c24SMarko Zec #endif
1113d4ce33dSBrooks Davis 
112ae5a19beSBrooks Davis 	/* XXX: destroying lo0 will lead to panics. */
113603724d3SBjoern A. Zeeb 	KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
1143d4ce33dSBrooks Davis 
1153d4ce33dSBrooks Davis 	bpfdetach(ifp);
1163d4ce33dSBrooks Davis 	if_detach(ifp);
117fc74a9f9SBrooks Davis 	if_free(ifp);
1183d4ce33dSBrooks Davis }
1193d4ce33dSBrooks Davis 
120bb2bfb4fSBrooks Davis static int
12108304c16SRobert Watson lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
12290d9802fSPeter Wemm {
1238b615593SMarko Zec 	INIT_VNET_NET(curvnet);
124fc74a9f9SBrooks Davis 	struct ifnet *ifp;
12590d9802fSPeter Wemm 
1266db9940fSEd Schouten 	ifp = if_alloc(IFT_LOOP);
1276db9940fSEd Schouten 	if (ifp == NULL)
128fc74a9f9SBrooks Davis 		return (ENOSPC);
12990d9802fSPeter Wemm 
130fc74a9f9SBrooks Davis 	if_initname(ifp, ifc->ifc_name, unit);
131fc74a9f9SBrooks Davis 	ifp->if_mtu = LOMTU;
132fc74a9f9SBrooks Davis 	ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
133fc74a9f9SBrooks Davis 	ifp->if_ioctl = loioctl;
134fc74a9f9SBrooks Davis 	ifp->if_output = looutput;
135fc74a9f9SBrooks Davis 	ifp->if_snd.ifq_maxlen = ifqmaxlen;
136fc74a9f9SBrooks Davis 	if_attach(ifp);
13701399f34SDavid Malone 	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
138603724d3SBjoern A. Zeeb 	if (V_loif == NULL)
139603724d3SBjoern A. Zeeb 		V_loif = ifp;
1403b16e7b2SMaxime Henrion 
1413b16e7b2SMaxime Henrion 	return (0);
14290d9802fSPeter Wemm }
14390d9802fSPeter Wemm 
1442b120974SPeter Wemm static int
1452b120974SPeter Wemm loop_modevent(module_t mod, int type, void *data)
146df8bae1dSRodney W. Grimes {
14797021c24SMarko Zec 	INIT_VNET_NET(curvnet);
14808304c16SRobert Watson 
1492b120974SPeter Wemm 	switch (type) {
1502b120974SPeter Wemm 	case MOD_LOAD:
15144e33a07SMarko Zec 		V_loif = NULL;
1523d4ce33dSBrooks Davis 		if_clone_attach(&lo_cloner);
1532b120974SPeter Wemm 		break;
15408304c16SRobert Watson 
1552b120974SPeter Wemm 	case MOD_UNLOAD:
1562b120974SPeter Wemm 		printf("loop module unload - not possible for this module type\n");
15708304c16SRobert Watson 		return (EINVAL);
15808304c16SRobert Watson 
1593e019deaSPoul-Henning Kamp 	default:
16008304c16SRobert Watson 		return (EOPNOTSUPP);
161f5fea3ddSPaul Traina 	}
16208304c16SRobert Watson 	return (0);
1632b120974SPeter Wemm }
1642b120974SPeter Wemm 
1652b120974SPeter Wemm static moduledata_t loop_mod = {
1662b120974SPeter Wemm 	"loop",
1672b120974SPeter Wemm 	loop_modevent,
1682b120974SPeter Wemm 	0
1692b120974SPeter Wemm };
1702b120974SPeter Wemm 
17178ece553SAlexander Kabaev DECLARE_MODULE(loop, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
172df8bae1dSRodney W. Grimes 
173cfa1ca9dSYoshinobu Inoue int
17408304c16SRobert Watson looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
17508304c16SRobert Watson     struct rtentry *rt)
176df8bae1dSRodney W. Grimes {
17701399f34SDavid Malone 	u_int32_t af;
17801399f34SDavid Malone 
179fe584538SDag-Erling Smørgrav 	M_ASSERTPKTHDR(m); /* check if we have the packet header */
180ed7509acSJulian Elischer 
181ed7509acSJulian Elischer 	if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
182ed7509acSJulian Elischer 		m_freem(m);
183ed7509acSJulian Elischer 		return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
184ed7509acSJulian Elischer 		        rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
185ed7509acSJulian Elischer 	}
18682cd038dSYoshinobu Inoue 
187ed7509acSJulian Elischer 	ifp->if_opackets++;
188ed7509acSJulian Elischer 	ifp->if_obytes += m->m_pkthdr.len;
18901399f34SDavid Malone 
19001399f34SDavid Malone 	/* BPF writes need to be handled specially. */
19101399f34SDavid Malone 	if (dst->sa_family == AF_UNSPEC) {
19201399f34SDavid Malone 		bcopy(dst->sa_data, &af, sizeof(af));
19301399f34SDavid Malone 		dst->sa_family = af;
19401399f34SDavid Malone 	}
19501399f34SDavid Malone 
196201c2527SJulian Elischer #if 1	/* XXX */
197201c2527SJulian Elischer 	switch (dst->sa_family) {
198201c2527SJulian Elischer 	case AF_INET:
19982cd038dSYoshinobu Inoue 	case AF_INET6:
200201c2527SJulian Elischer 	case AF_IPX:
201201c2527SJulian Elischer 	case AF_APPLETALK:
20205b3ccefSJulian Elischer 		break;
203201c2527SJulian Elischer 	default:
20471582bf5SRobert Watson 		printf("looutput: af=%d unexpected\n", dst->sa_family);
205201c2527SJulian Elischer 		m_freem(m);
206201c2527SJulian Elischer 		return (EAFNOSUPPORT);
207201c2527SJulian Elischer 	}
208201c2527SJulian Elischer #endif
20906a429a3SArchie Cobbs 	return (if_simloop(ifp, m, dst->sa_family, 0));
210ed7509acSJulian Elischer }
211ed7509acSJulian Elischer 
212ed7509acSJulian Elischer /*
213ed7509acSJulian Elischer  * if_simloop()
214ed7509acSJulian Elischer  *
215ed7509acSJulian Elischer  * This function is to support software emulation of hardware loopback,
216ed7509acSJulian Elischer  * i.e., for interfaces with the IFF_SIMPLEX attribute. Since they can't
217ed7509acSJulian Elischer  * hear their own broadcasts, we create a copy of the packet that we
218ed7509acSJulian Elischer  * would normally receive via a hardware loopback.
219ed7509acSJulian Elischer  *
220ed7509acSJulian Elischer  * This function expects the packet to include the media header of length hlen.
221ed7509acSJulian Elischer  */
222ed7509acSJulian Elischer int
22308304c16SRobert Watson if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen)
224ed7509acSJulian Elischer {
2258b615593SMarko Zec 	INIT_VNET_NET(ifp->if_vnet);
226df5e1987SJonathan Lemon 	int isr;
227df8bae1dSRodney W. Grimes 
228fe584538SDag-Erling Smørgrav 	M_ASSERTPKTHDR(m);
2299c855a36SSam Leffler 	m_tag_delete_nonpersistent(m);
230ed7509acSJulian Elischer 	m->m_pkthdr.rcvif = ifp;
23106a429a3SArchie Cobbs 
2328343821bSSUZUKI Shinsuke 	/*
2338343821bSSUZUKI Shinsuke 	 * Let BPF see incoming packet in the following manner:
2348343821bSSUZUKI Shinsuke 	 *  - Emulated packet loopback for a simplex interface
2358343821bSSUZUKI Shinsuke 	 *    (net/if_ethersubr.c)
2368343821bSSUZUKI Shinsuke 	 *	-> passes it to ifp's BPF
2378343821bSSUZUKI Shinsuke 	 *  - IPv4/v6 multicast packet loopback (netinet(6)/ip(6)_output.c)
2388343821bSSUZUKI Shinsuke 	 *	-> not passes it to any BPF
2398343821bSSUZUKI Shinsuke 	 *  - Normal packet loopback from myself to myself (net/if_loop.c)
2408343821bSSUZUKI Shinsuke 	 *	-> passes to lo0's BPF (even in case of IPv6, where ifp!=lo0)
2418343821bSSUZUKI Shinsuke 	 */
2428343821bSSUZUKI Shinsuke 	if (hlen > 0) {
24316d878ccSChristian S.J. Peron 		if (bpf_peers_present(ifp->if_bpf)) {
2448343821bSSUZUKI Shinsuke 			bpf_mtap(ifp->if_bpf, m);
2458343821bSSUZUKI Shinsuke 		}
2468343821bSSUZUKI Shinsuke 	} else {
247603724d3SBjoern A. Zeeb 		if (bpf_peers_present(V_loif->if_bpf)) {
248603724d3SBjoern A. Zeeb 			if ((m->m_flags & M_MCAST) == 0 || V_loif == ifp) {
2498343821bSSUZUKI Shinsuke 				/* XXX beware sizeof(af) != 4 */
2508343821bSSUZUKI Shinsuke 				u_int32_t af1 = af;
2518343821bSSUZUKI Shinsuke 
252df8bae1dSRodney W. Grimes 				/*
253437ffe18SSam Leffler 				 * We need to prepend the address family.
254df8bae1dSRodney W. Grimes 				 */
255603724d3SBjoern A. Zeeb 				bpf_mtap2(V_loif->if_bpf, &af1, sizeof(af1), m);
2568343821bSSUZUKI Shinsuke 			}
2578343821bSSUZUKI Shinsuke 		}
258df8bae1dSRodney W. Grimes 	}
259df8bae1dSRodney W. Grimes 
260ed7509acSJulian Elischer 	/* Strip away media header */
2613a43ad8fSDoug Rabson 	if (hlen > 0) {
262fe81f64fSAndrew Gallatin 		m_adj(m, hlen);
263f6966ecdSOlivier Houchard #ifndef __NO_STRICT_ALIGNMENT
26473dbd3daSJohn Baldwin 		/*
26573dbd3daSJohn Baldwin 		 * Some archs do not like unaligned data, so
26673dbd3daSJohn Baldwin 		 * we move data down in the first mbuf.
26773dbd3daSJohn Baldwin 		 */
268fe81f64fSAndrew Gallatin 		if (mtod(m, vm_offset_t) & 3) {
26960ed92ddSMatt Jacob 			KASSERT(hlen >= 3, ("if_simloop: hlen too small"));
270fe81f64fSAndrew Gallatin 			bcopy(m->m_data,
271fe81f64fSAndrew Gallatin 			    (char *)(mtod(m, vm_offset_t)
272fe81f64fSAndrew Gallatin 				- (mtod(m, vm_offset_t) & 3)),
273fe81f64fSAndrew Gallatin 			    m->m_len);
274445e045bSAlexander Kabaev 			m->m_data -= (mtod(m,vm_offset_t) & 3);
275fe81f64fSAndrew Gallatin 		}
2763a43ad8fSDoug Rabson #endif
2773a43ad8fSDoug Rabson 	}
278ed7509acSJulian Elischer 
27906a429a3SArchie Cobbs 	/* Deliver to upper layer protocol */
28006a429a3SArchie Cobbs 	switch (af) {
281df8bae1dSRodney W. Grimes #ifdef INET
282df8bae1dSRodney W. Grimes 	case AF_INET:
283df8bae1dSRodney W. Grimes 		isr = NETISR_IP;
284df8bae1dSRodney W. Grimes 		break;
285df8bae1dSRodney W. Grimes #endif
28682cd038dSYoshinobu Inoue #ifdef INET6
28782cd038dSYoshinobu Inoue 	case AF_INET6:
28882cd038dSYoshinobu Inoue 		m->m_flags |= M_LOOP;
28982cd038dSYoshinobu Inoue 		isr = NETISR_IPV6;
29082cd038dSYoshinobu Inoue 		break;
29182cd038dSYoshinobu Inoue #endif
292cc6a66f2SJulian Elischer #ifdef IPX
293cc6a66f2SJulian Elischer 	case AF_IPX:
294cc6a66f2SJulian Elischer 		isr = NETISR_IPX;
295cc6a66f2SJulian Elischer 		break;
296cc6a66f2SJulian Elischer #endif
297655929bfSJulian Elischer #ifdef NETATALK
298655929bfSJulian Elischer 	case AF_APPLETALK:
2991cafed39SJonathan Lemon 		isr = NETISR_ATALK2;
300655929bfSJulian Elischer 		break;
3018cdfefbdSPeter Wemm #endif
302df8bae1dSRodney W. Grimes 	default:
30306a429a3SArchie Cobbs 		printf("if_simloop: can't handle af=%d\n", af);
304df8bae1dSRodney W. Grimes 		m_freem(m);
305df8bae1dSRodney W. Grimes 		return (EAFNOSUPPORT);
306df8bae1dSRodney W. Grimes 	}
307df8bae1dSRodney W. Grimes 	ifp->if_ipackets++;
308df8bae1dSRodney W. Grimes 	ifp->if_ibytes += m->m_pkthdr.len;
3093161f583SAndre Oppermann 	netisr_queue(isr, m);	/* mbuf is free'd on failure. */
310df8bae1dSRodney W. Grimes 	return (0);
311df8bae1dSRodney W. Grimes }
312df8bae1dSRodney W. Grimes 
313df8bae1dSRodney W. Grimes /* ARGSUSED */
3143bda9f9bSPoul-Henning Kamp static void
31508304c16SRobert Watson lortrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
316df8bae1dSRodney W. Grimes {
31708304c16SRobert Watson 
318d1dd20beSSam Leffler 	RT_LOCK_ASSERT(rt);
31997d8d152SAndre Oppermann 	rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu;
320df8bae1dSRodney W. Grimes }
321df8bae1dSRodney W. Grimes 
322df8bae1dSRodney W. Grimes /*
323df8bae1dSRodney W. Grimes  * Process an ioctl request.
324df8bae1dSRodney W. Grimes  */
325df8bae1dSRodney W. Grimes /* ARGSUSED */
326cfa1ca9dSYoshinobu Inoue int
32708304c16SRobert Watson loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
328df8bae1dSRodney W. Grimes {
32908304c16SRobert Watson 	struct ifaddr *ifa;
33008304c16SRobert Watson 	struct ifreq *ifr = (struct ifreq *)data;
33108304c16SRobert Watson 	int error = 0;
332df8bae1dSRodney W. Grimes 
333df8bae1dSRodney W. Grimes 	switch (cmd) {
334df8bae1dSRodney W. Grimes 	case SIOCSIFADDR:
33513f4c340SRobert Watson 		ifp->if_flags |= IFF_UP;
33613f4c340SRobert Watson 		ifp->if_drv_flags |= IFF_DRV_RUNNING;
337df8bae1dSRodney W. Grimes 		ifa = (struct ifaddr *)data;
338df8bae1dSRodney W. Grimes 		ifa->ifa_rtrequest = lortrequest;
339df8bae1dSRodney W. Grimes 		/*
340df8bae1dSRodney W. Grimes 		 * Everything else is done at a higher level.
341df8bae1dSRodney W. Grimes 		 */
342df8bae1dSRodney W. Grimes 		break;
343df8bae1dSRodney W. Grimes 
344df8bae1dSRodney W. Grimes 	case SIOCADDMULTI:
345df8bae1dSRodney W. Grimes 	case SIOCDELMULTI:
346df8bae1dSRodney W. Grimes 		if (ifr == 0) {
347df8bae1dSRodney W. Grimes 			error = EAFNOSUPPORT;		/* XXX */
348df8bae1dSRodney W. Grimes 			break;
349df8bae1dSRodney W. Grimes 		}
350df8bae1dSRodney W. Grimes 		switch (ifr->ifr_addr.sa_family) {
351df8bae1dSRodney W. Grimes 
352df8bae1dSRodney W. Grimes #ifdef INET
353df8bae1dSRodney W. Grimes 		case AF_INET:
354df8bae1dSRodney W. Grimes 			break;
355df8bae1dSRodney W. Grimes #endif
35682cd038dSYoshinobu Inoue #ifdef INET6
35782cd038dSYoshinobu Inoue 		case AF_INET6:
35882cd038dSYoshinobu Inoue 			break;
35982cd038dSYoshinobu Inoue #endif
360df8bae1dSRodney W. Grimes 
361df8bae1dSRodney W. Grimes 		default:
362df8bae1dSRodney W. Grimes 			error = EAFNOSUPPORT;
363df8bae1dSRodney W. Grimes 			break;
364df8bae1dSRodney W. Grimes 		}
365df8bae1dSRodney W. Grimes 		break;
366df8bae1dSRodney W. Grimes 
36790fd8c38SDavid Greenman 	case SIOCSIFMTU:
36890fd8c38SDavid Greenman 		ifp->if_mtu = ifr->ifr_mtu;
36990fd8c38SDavid Greenman 		break;
37090fd8c38SDavid Greenman 
371ce42f1fbSPoul-Henning Kamp 	case SIOCSIFFLAGS:
372ce42f1fbSPoul-Henning Kamp 		break;
373ce42f1fbSPoul-Henning Kamp 
374df8bae1dSRodney W. Grimes 	default:
375df8bae1dSRodney W. Grimes 		error = EINVAL;
376df8bae1dSRodney W. Grimes 	}
377df8bae1dSRodney W. Grimes 	return (error);
378df8bae1dSRodney W. Grimes }
379