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" 4133553d6eSBjoern A. Zeeb #include "opt_route.h" 423dc85f8dSRobert Watson #include "opt_mac.h" 43430df5f4SEivind Eklund 44df8bae1dSRodney W. Grimes #include <sys/param.h> 45df8bae1dSRodney W. Grimes #include <sys/systm.h> 46df8bae1dSRodney W. Grimes #include <sys/kernel.h> 47df8bae1dSRodney W. Grimes #include <sys/mbuf.h> 482b120974SPeter Wemm #include <sys/module.h> 493d4ce33dSBrooks Davis #include <machine/bus.h> 503d4ce33dSBrooks Davis #include <sys/rman.h> 51df8bae1dSRodney W. Grimes #include <sys/socket.h> 5251a53488SBruce Evans #include <sys/sockio.h> 5390d9802fSPeter Wemm #include <sys/sysctl.h> 54603724d3SBjoern A. Zeeb #include <sys/vimage.h> 55df8bae1dSRodney W. Grimes 56df8bae1dSRodney W. Grimes #include <net/if.h> 57f889d2efSBrooks Davis #include <net/if_clone.h> 58df8bae1dSRodney W. Grimes #include <net/if_types.h> 59df8bae1dSRodney W. Grimes #include <net/netisr.h> 60df8bae1dSRodney W. Grimes #include <net/route.h> 61df8bae1dSRodney W. Grimes #include <net/bpf.h> 624b79449eSBjoern A. Zeeb #include <net/vnet.h> 63df8bae1dSRodney W. Grimes 64df8bae1dSRodney W. Grimes #ifdef INET 65df8bae1dSRodney W. Grimes #include <netinet/in.h> 66df8bae1dSRodney W. Grimes #include <netinet/in_var.h> 67df8bae1dSRodney W. Grimes #endif 68df8bae1dSRodney W. Grimes 69cc6a66f2SJulian Elischer #ifdef IPX 70cc6a66f2SJulian Elischer #include <netipx/ipx.h> 71cc6a66f2SJulian Elischer #include <netipx/ipx_if.h> 72cc6a66f2SJulian Elischer #endif 73cc6a66f2SJulian Elischer 7482cd038dSYoshinobu Inoue #ifdef INET6 7582cd038dSYoshinobu Inoue #ifndef INET 7682cd038dSYoshinobu Inoue #include <netinet/in.h> 7782cd038dSYoshinobu Inoue #endif 7882cd038dSYoshinobu Inoue #include <netinet6/in6_var.h> 79686cdd19SJun-ichiro itojun Hagino #include <netinet/ip6.h> 8082cd038dSYoshinobu Inoue #endif 8182cd038dSYoshinobu Inoue 82655929bfSJulian Elischer #ifdef NETATALK 83655929bfSJulian Elischer #include <netatalk/at.h> 84655929bfSJulian Elischer #include <netatalk/at_var.h> 858cdfefbdSPeter Wemm #endif 86655929bfSJulian Elischer 873dc85f8dSRobert Watson #include <security/mac/mac_framework.h> 883dc85f8dSRobert Watson 89db8889c6SDavid Greenman #ifdef TINY_LOMTU 90df8bae1dSRodney W. Grimes #define LOMTU (1024+512) 9182cd038dSYoshinobu Inoue #elif defined(LARGE_LOMTU) 9282cd038dSYoshinobu Inoue #define LOMTU 131072 93db8889c6SDavid Greenman #else 94af78195eSDavid Greenman #define LOMTU 16384 95db8889c6SDavid Greenman #endif 96df8bae1dSRodney W. Grimes 973d4ce33dSBrooks Davis int loioctl(struct ifnet *, u_long, caddr_t); 983d4ce33dSBrooks Davis static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); 993d4ce33dSBrooks Davis int looutput(struct ifnet *ifp, struct mbuf *m, 1003d4ce33dSBrooks Davis struct sockaddr *dst, struct rtentry *rt); 1016b7330e2SSam Leffler static int lo_clone_create(struct if_clone *, int, caddr_t); 102bb2bfb4fSBrooks Davis static void lo_clone_destroy(struct ifnet *); 1033d4ce33dSBrooks Davis 10444e33a07SMarko Zec #ifdef VIMAGE_GLOBALS 10544e33a07SMarko Zec struct ifnet *loif; /* Used externally */ 10644e33a07SMarko Zec #endif 1073d4ce33dSBrooks Davis 108f889d2efSBrooks Davis IFC_SIMPLE_DECLARE(lo, 1); 1093d4ce33dSBrooks Davis 110bb2bfb4fSBrooks Davis static void 11108304c16SRobert Watson lo_clone_destroy(struct ifnet *ifp) 1123d4ce33dSBrooks Davis { 11397021c24SMarko Zec #ifdef INVARIANTS 11497021c24SMarko Zec INIT_VNET_NET(ifp->if_vnet); 11597021c24SMarko Zec #endif 1163d4ce33dSBrooks Davis 117ae5a19beSBrooks Davis /* XXX: destroying lo0 will lead to panics. */ 118603724d3SBjoern A. Zeeb KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__)); 1193d4ce33dSBrooks Davis 1203d4ce33dSBrooks Davis bpfdetach(ifp); 1213d4ce33dSBrooks Davis if_detach(ifp); 122fc74a9f9SBrooks Davis if_free(ifp); 1233d4ce33dSBrooks Davis } 1243d4ce33dSBrooks Davis 125bb2bfb4fSBrooks Davis static int 12608304c16SRobert Watson lo_clone_create(struct if_clone *ifc, int unit, caddr_t params) 12790d9802fSPeter Wemm { 1288b615593SMarko Zec INIT_VNET_NET(curvnet); 129fc74a9f9SBrooks Davis struct ifnet *ifp; 13090d9802fSPeter Wemm 1316db9940fSEd Schouten ifp = if_alloc(IFT_LOOP); 1326db9940fSEd Schouten if (ifp == NULL) 133fc74a9f9SBrooks Davis return (ENOSPC); 13490d9802fSPeter Wemm 135fc74a9f9SBrooks Davis if_initname(ifp, ifc->ifc_name, unit); 136fc74a9f9SBrooks Davis ifp->if_mtu = LOMTU; 137fc74a9f9SBrooks Davis ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; 138fc74a9f9SBrooks Davis ifp->if_ioctl = loioctl; 139fc74a9f9SBrooks Davis ifp->if_output = looutput; 140fc74a9f9SBrooks Davis ifp->if_snd.ifq_maxlen = ifqmaxlen; 141fc74a9f9SBrooks Davis if_attach(ifp); 14201399f34SDavid Malone bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); 143603724d3SBjoern A. Zeeb if (V_loif == NULL) 144603724d3SBjoern A. Zeeb V_loif = ifp; 1453b16e7b2SMaxime Henrion 1463b16e7b2SMaxime Henrion return (0); 14790d9802fSPeter Wemm } 14890d9802fSPeter Wemm 1492b120974SPeter Wemm static int 1502b120974SPeter Wemm loop_modevent(module_t mod, int type, void *data) 151df8bae1dSRodney W. Grimes { 15297021c24SMarko Zec INIT_VNET_NET(curvnet); 15308304c16SRobert Watson 1542b120974SPeter Wemm switch (type) { 1552b120974SPeter Wemm case MOD_LOAD: 15644e33a07SMarko Zec V_loif = NULL; 1573d4ce33dSBrooks Davis if_clone_attach(&lo_cloner); 1582b120974SPeter Wemm break; 15908304c16SRobert Watson 1602b120974SPeter Wemm case MOD_UNLOAD: 1612b120974SPeter Wemm printf("loop module unload - not possible for this module type\n"); 16208304c16SRobert Watson return (EINVAL); 16308304c16SRobert Watson 1643e019deaSPoul-Henning Kamp default: 16508304c16SRobert Watson return (EOPNOTSUPP); 166f5fea3ddSPaul Traina } 16708304c16SRobert Watson return (0); 1682b120974SPeter Wemm } 1692b120974SPeter Wemm 1702b120974SPeter Wemm static moduledata_t loop_mod = { 1712b120974SPeter Wemm "loop", 1722b120974SPeter Wemm loop_modevent, 1732b120974SPeter Wemm 0 1742b120974SPeter Wemm }; 1752b120974SPeter Wemm 17678ece553SAlexander Kabaev DECLARE_MODULE(loop, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); 177df8bae1dSRodney W. Grimes 178cfa1ca9dSYoshinobu Inoue int 17908304c16SRobert Watson looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, 18008304c16SRobert Watson struct rtentry *rt) 181df8bae1dSRodney W. Grimes { 18201399f34SDavid Malone u_int32_t af; 1833dc85f8dSRobert Watson #ifdef MAC 1843dc85f8dSRobert Watson int error; 1853dc85f8dSRobert Watson #endif 18601399f34SDavid Malone 187fe584538SDag-Erling Smørgrav M_ASSERTPKTHDR(m); /* check if we have the packet header */ 188ed7509acSJulian Elischer 1893dc85f8dSRobert Watson #ifdef MAC 1903dc85f8dSRobert Watson error = mac_ifnet_check_transmit(ifp, m); 1913dc85f8dSRobert Watson if (error) { 1923dc85f8dSRobert Watson m_freem(m); 1933dc85f8dSRobert Watson return (error); 1943dc85f8dSRobert Watson } 1953dc85f8dSRobert Watson #endif 1963dc85f8dSRobert Watson 197ed7509acSJulian Elischer if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { 198ed7509acSJulian Elischer m_freem(m); 199ed7509acSJulian Elischer return (rt->rt_flags & RTF_BLACKHOLE ? 0 : 200ed7509acSJulian Elischer rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); 201ed7509acSJulian Elischer } 20282cd038dSYoshinobu Inoue 203ed7509acSJulian Elischer ifp->if_opackets++; 204ed7509acSJulian Elischer ifp->if_obytes += m->m_pkthdr.len; 20501399f34SDavid Malone 20601399f34SDavid Malone /* BPF writes need to be handled specially. */ 20701399f34SDavid Malone if (dst->sa_family == AF_UNSPEC) { 20801399f34SDavid Malone bcopy(dst->sa_data, &af, sizeof(af)); 20901399f34SDavid Malone dst->sa_family = af; 21001399f34SDavid Malone } 21101399f34SDavid Malone 212201c2527SJulian Elischer #if 1 /* XXX */ 213201c2527SJulian Elischer switch (dst->sa_family) { 214201c2527SJulian Elischer case AF_INET: 21582cd038dSYoshinobu Inoue case AF_INET6: 216201c2527SJulian Elischer case AF_IPX: 217201c2527SJulian Elischer case AF_APPLETALK: 21805b3ccefSJulian Elischer break; 219201c2527SJulian Elischer default: 22071582bf5SRobert Watson printf("looutput: af=%d unexpected\n", dst->sa_family); 221201c2527SJulian Elischer m_freem(m); 222201c2527SJulian Elischer return (EAFNOSUPPORT); 223201c2527SJulian Elischer } 224201c2527SJulian Elischer #endif 22506a429a3SArchie Cobbs return (if_simloop(ifp, m, dst->sa_family, 0)); 226ed7509acSJulian Elischer } 227ed7509acSJulian Elischer 228ed7509acSJulian Elischer /* 229ed7509acSJulian Elischer * if_simloop() 230ed7509acSJulian Elischer * 231ed7509acSJulian Elischer * This function is to support software emulation of hardware loopback, 232ed7509acSJulian Elischer * i.e., for interfaces with the IFF_SIMPLEX attribute. Since they can't 233ed7509acSJulian Elischer * hear their own broadcasts, we create a copy of the packet that we 234ed7509acSJulian Elischer * would normally receive via a hardware loopback. 235ed7509acSJulian Elischer * 236ed7509acSJulian Elischer * This function expects the packet to include the media header of length hlen. 237ed7509acSJulian Elischer */ 238ed7509acSJulian Elischer int 23908304c16SRobert Watson if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen) 240ed7509acSJulian Elischer { 2418b615593SMarko Zec INIT_VNET_NET(ifp->if_vnet); 242df5e1987SJonathan Lemon int isr; 243df8bae1dSRodney W. Grimes 244fe584538SDag-Erling Smørgrav M_ASSERTPKTHDR(m); 2459c855a36SSam Leffler m_tag_delete_nonpersistent(m); 246ed7509acSJulian Elischer m->m_pkthdr.rcvif = ifp; 24706a429a3SArchie Cobbs 2483dc85f8dSRobert Watson #ifdef MAC 2493dc85f8dSRobert Watson mac_ifnet_create_mbuf(ifp, m); 2503dc85f8dSRobert Watson #endif 2513dc85f8dSRobert Watson 2528343821bSSUZUKI Shinsuke /* 2538343821bSSUZUKI Shinsuke * Let BPF see incoming packet in the following manner: 2548343821bSSUZUKI Shinsuke * - Emulated packet loopback for a simplex interface 2558343821bSSUZUKI Shinsuke * (net/if_ethersubr.c) 2568343821bSSUZUKI Shinsuke * -> passes it to ifp's BPF 2578343821bSSUZUKI Shinsuke * - IPv4/v6 multicast packet loopback (netinet(6)/ip(6)_output.c) 2588343821bSSUZUKI Shinsuke * -> not passes it to any BPF 2598343821bSSUZUKI Shinsuke * - Normal packet loopback from myself to myself (net/if_loop.c) 2608343821bSSUZUKI Shinsuke * -> passes to lo0's BPF (even in case of IPv6, where ifp!=lo0) 2618343821bSSUZUKI Shinsuke */ 2628343821bSSUZUKI Shinsuke if (hlen > 0) { 26316d878ccSChristian S.J. Peron if (bpf_peers_present(ifp->if_bpf)) { 2648343821bSSUZUKI Shinsuke bpf_mtap(ifp->if_bpf, m); 2658343821bSSUZUKI Shinsuke } 2668343821bSSUZUKI Shinsuke } else { 267603724d3SBjoern A. Zeeb if (bpf_peers_present(V_loif->if_bpf)) { 268603724d3SBjoern A. Zeeb if ((m->m_flags & M_MCAST) == 0 || V_loif == ifp) { 2698343821bSSUZUKI Shinsuke /* XXX beware sizeof(af) != 4 */ 2708343821bSSUZUKI Shinsuke u_int32_t af1 = af; 2718343821bSSUZUKI Shinsuke 272df8bae1dSRodney W. Grimes /* 273437ffe18SSam Leffler * We need to prepend the address family. 274df8bae1dSRodney W. Grimes */ 275603724d3SBjoern A. Zeeb bpf_mtap2(V_loif->if_bpf, &af1, sizeof(af1), m); 2768343821bSSUZUKI Shinsuke } 2778343821bSSUZUKI Shinsuke } 278df8bae1dSRodney W. Grimes } 279df8bae1dSRodney W. Grimes 280ed7509acSJulian Elischer /* Strip away media header */ 2813a43ad8fSDoug Rabson if (hlen > 0) { 282fe81f64fSAndrew Gallatin m_adj(m, hlen); 283f6966ecdSOlivier Houchard #ifndef __NO_STRICT_ALIGNMENT 28473dbd3daSJohn Baldwin /* 28573dbd3daSJohn Baldwin * Some archs do not like unaligned data, so 28673dbd3daSJohn Baldwin * we move data down in the first mbuf. 28773dbd3daSJohn Baldwin */ 288fe81f64fSAndrew Gallatin if (mtod(m, vm_offset_t) & 3) { 28960ed92ddSMatt Jacob KASSERT(hlen >= 3, ("if_simloop: hlen too small")); 290fe81f64fSAndrew Gallatin bcopy(m->m_data, 291fe81f64fSAndrew Gallatin (char *)(mtod(m, vm_offset_t) 292fe81f64fSAndrew Gallatin - (mtod(m, vm_offset_t) & 3)), 293fe81f64fSAndrew Gallatin m->m_len); 294445e045bSAlexander Kabaev m->m_data -= (mtod(m,vm_offset_t) & 3); 295fe81f64fSAndrew Gallatin } 2963a43ad8fSDoug Rabson #endif 2973a43ad8fSDoug Rabson } 298ed7509acSJulian Elischer 29906a429a3SArchie Cobbs /* Deliver to upper layer protocol */ 30006a429a3SArchie Cobbs switch (af) { 301df8bae1dSRodney W. Grimes #ifdef INET 302df8bae1dSRodney W. Grimes case AF_INET: 303df8bae1dSRodney W. Grimes isr = NETISR_IP; 304df8bae1dSRodney W. Grimes break; 305df8bae1dSRodney W. Grimes #endif 30682cd038dSYoshinobu Inoue #ifdef INET6 30782cd038dSYoshinobu Inoue case AF_INET6: 30882cd038dSYoshinobu Inoue m->m_flags |= M_LOOP; 30982cd038dSYoshinobu Inoue isr = NETISR_IPV6; 31082cd038dSYoshinobu Inoue break; 31182cd038dSYoshinobu Inoue #endif 312cc6a66f2SJulian Elischer #ifdef IPX 313cc6a66f2SJulian Elischer case AF_IPX: 314cc6a66f2SJulian Elischer isr = NETISR_IPX; 315cc6a66f2SJulian Elischer break; 316cc6a66f2SJulian Elischer #endif 317655929bfSJulian Elischer #ifdef NETATALK 318655929bfSJulian Elischer case AF_APPLETALK: 3191cafed39SJonathan Lemon isr = NETISR_ATALK2; 320655929bfSJulian Elischer break; 3218cdfefbdSPeter Wemm #endif 322df8bae1dSRodney W. Grimes default: 32306a429a3SArchie Cobbs printf("if_simloop: can't handle af=%d\n", af); 324df8bae1dSRodney W. Grimes m_freem(m); 325df8bae1dSRodney W. Grimes return (EAFNOSUPPORT); 326df8bae1dSRodney W. Grimes } 327df8bae1dSRodney W. Grimes ifp->if_ipackets++; 328df8bae1dSRodney W. Grimes ifp->if_ibytes += m->m_pkthdr.len; 3293161f583SAndre Oppermann netisr_queue(isr, m); /* mbuf is free'd on failure. */ 330df8bae1dSRodney W. Grimes return (0); 331df8bae1dSRodney W. Grimes } 332df8bae1dSRodney W. Grimes 333df8bae1dSRodney W. Grimes /* ARGSUSED */ 3343bda9f9bSPoul-Henning Kamp static void 33508304c16SRobert Watson lortrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info) 336df8bae1dSRodney W. Grimes { 33708304c16SRobert Watson 338d1dd20beSSam Leffler RT_LOCK_ASSERT(rt); 33997d8d152SAndre Oppermann rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; 340df8bae1dSRodney W. Grimes } 341df8bae1dSRodney W. Grimes 342df8bae1dSRodney W. Grimes /* 343df8bae1dSRodney W. Grimes * Process an ioctl request. 344df8bae1dSRodney W. Grimes */ 345df8bae1dSRodney W. Grimes /* ARGSUSED */ 346cfa1ca9dSYoshinobu Inoue int 34708304c16SRobert Watson loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 348df8bae1dSRodney W. Grimes { 34908304c16SRobert Watson struct ifaddr *ifa; 35008304c16SRobert Watson struct ifreq *ifr = (struct ifreq *)data; 35108304c16SRobert Watson int error = 0; 352df8bae1dSRodney W. Grimes 353df8bae1dSRodney W. Grimes switch (cmd) { 354df8bae1dSRodney W. Grimes case SIOCSIFADDR: 35513f4c340SRobert Watson ifp->if_flags |= IFF_UP; 35613f4c340SRobert Watson ifp->if_drv_flags |= IFF_DRV_RUNNING; 357df8bae1dSRodney W. Grimes ifa = (struct ifaddr *)data; 358df8bae1dSRodney W. Grimes ifa->ifa_rtrequest = lortrequest; 359df8bae1dSRodney W. Grimes /* 360df8bae1dSRodney W. Grimes * Everything else is done at a higher level. 361df8bae1dSRodney W. Grimes */ 362df8bae1dSRodney W. Grimes break; 363df8bae1dSRodney W. Grimes 364df8bae1dSRodney W. Grimes case SIOCADDMULTI: 365df8bae1dSRodney W. Grimes case SIOCDELMULTI: 366df8bae1dSRodney W. Grimes if (ifr == 0) { 367df8bae1dSRodney W. Grimes error = EAFNOSUPPORT; /* XXX */ 368df8bae1dSRodney W. Grimes break; 369df8bae1dSRodney W. Grimes } 370df8bae1dSRodney W. Grimes switch (ifr->ifr_addr.sa_family) { 371df8bae1dSRodney W. Grimes 372df8bae1dSRodney W. Grimes #ifdef INET 373df8bae1dSRodney W. Grimes case AF_INET: 374df8bae1dSRodney W. Grimes break; 375df8bae1dSRodney W. Grimes #endif 37682cd038dSYoshinobu Inoue #ifdef INET6 37782cd038dSYoshinobu Inoue case AF_INET6: 37882cd038dSYoshinobu Inoue break; 37982cd038dSYoshinobu Inoue #endif 380df8bae1dSRodney W. Grimes 381df8bae1dSRodney W. Grimes default: 382df8bae1dSRodney W. Grimes error = EAFNOSUPPORT; 383df8bae1dSRodney W. Grimes break; 384df8bae1dSRodney W. Grimes } 385df8bae1dSRodney W. Grimes break; 386df8bae1dSRodney W. Grimes 38790fd8c38SDavid Greenman case SIOCSIFMTU: 38890fd8c38SDavid Greenman ifp->if_mtu = ifr->ifr_mtu; 38990fd8c38SDavid Greenman break; 39090fd8c38SDavid Greenman 391ce42f1fbSPoul-Henning Kamp case SIOCSIFFLAGS: 392ce42f1fbSPoul-Henning Kamp break; 393ce42f1fbSPoul-Henning Kamp 394df8bae1dSRodney W. Grimes default: 395df8bae1dSRodney W. Grimes error = EINVAL; 396df8bae1dSRodney W. Grimes } 397df8bae1dSRodney W. Grimes return (error); 398df8bae1dSRodney W. Grimes } 399