Home | History | Annotate | Line # | Download | only in net
if_loop.c revision 1.62
      1  1.62  christos /*	$NetBSD: if_loop.c,v 1.62 2006/11/16 01:33:40 christos Exp $	*/
      2  1.26    itojun 
      3  1.26    itojun /*
      4  1.26    itojun  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      5  1.26    itojun  * All rights reserved.
      6  1.55     perry  *
      7  1.26    itojun  * Redistribution and use in source and binary forms, with or without
      8  1.26    itojun  * modification, are permitted provided that the following conditions
      9  1.26    itojun  * are met:
     10  1.26    itojun  * 1. Redistributions of source code must retain the above copyright
     11  1.26    itojun  *    notice, this list of conditions and the following disclaimer.
     12  1.26    itojun  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.26    itojun  *    notice, this list of conditions and the following disclaimer in the
     14  1.26    itojun  *    documentation and/or other materials provided with the distribution.
     15  1.26    itojun  * 3. Neither the name of the project nor the names of its contributors
     16  1.26    itojun  *    may be used to endorse or promote products derived from this software
     17  1.26    itojun  *    without specific prior written permission.
     18  1.55     perry  *
     19  1.26    itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     20  1.26    itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  1.26    itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  1.26    itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     23  1.26    itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  1.26    itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  1.26    itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  1.26    itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  1.26    itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  1.26    itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  1.26    itojun  * SUCH DAMAGE.
     30  1.26    itojun  */
     31  1.12       cgd 
     32   1.1       cgd /*
     33  1.11   mycroft  * Copyright (c) 1982, 1986, 1993
     34  1.11   mycroft  *	The Regents of the University of California.  All rights reserved.
     35   1.1       cgd  *
     36   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     37   1.1       cgd  * modification, are permitted provided that the following conditions
     38   1.1       cgd  * are met:
     39   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     40   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     41   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     42   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     43   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     44  1.47       agc  * 3. Neither the name of the University nor the names of its contributors
     45   1.1       cgd  *    may be used to endorse or promote products derived from this software
     46   1.1       cgd  *    without specific prior written permission.
     47   1.1       cgd  *
     48   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     49   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     50   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     51   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     52   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     53   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     54   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     55   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     56   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     57   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     58   1.1       cgd  * SUCH DAMAGE.
     59   1.1       cgd  *
     60  1.21      fvdl  *	@(#)if_loop.c	8.2 (Berkeley) 1/9/95
     61   1.1       cgd  */
     62   1.1       cgd 
     63   1.1       cgd /*
     64   1.1       cgd  * Loopback interface driver for protocol testing and timing.
     65   1.1       cgd  */
     66  1.40     lukem 
     67  1.40     lukem #include <sys/cdefs.h>
     68  1.62  christos __KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.62 2006/11/16 01:33:40 christos Exp $");
     69  1.23  jonathan 
     70  1.23  jonathan #include "opt_inet.h"
     71  1.23  jonathan #include "opt_atalk.h"
     72  1.24  jonathan #include "opt_iso.h"
     73  1.46    martin #include "opt_ipx.h"
     74  1.46    martin #include "opt_mbuftrace.h"
     75   1.1       cgd 
     76   1.9   mycroft #include "bpfilter.h"
     77   1.4       cgd 
     78   1.9   mycroft #include <sys/param.h>
     79   1.9   mycroft #include <sys/systm.h>
     80  1.11   mycroft #include <sys/kernel.h>
     81   1.9   mycroft #include <sys/mbuf.h>
     82   1.9   mycroft #include <sys/socket.h>
     83   1.9   mycroft #include <sys/errno.h>
     84   1.9   mycroft #include <sys/ioctl.h>
     85  1.11   mycroft #include <sys/time.h>
     86  1.11   mycroft 
     87  1.11   mycroft #include <machine/cpu.h>
     88   1.9   mycroft 
     89   1.9   mycroft #include <net/if.h>
     90   1.9   mycroft #include <net/if_types.h>
     91   1.9   mycroft #include <net/netisr.h>
     92   1.9   mycroft #include <net/route.h>
     93   1.1       cgd 
     94   1.1       cgd #ifdef	INET
     95   1.9   mycroft #include <netinet/in.h>
     96   1.9   mycroft #include <netinet/in_systm.h>
     97   1.9   mycroft #include <netinet/in_var.h>
     98   1.9   mycroft #include <netinet/ip.h>
     99   1.1       cgd #endif
    100   1.1       cgd 
    101  1.26    itojun #ifdef INET6
    102  1.26    itojun #ifndef INET
    103  1.26    itojun #include <netinet/in.h>
    104  1.26    itojun #endif
    105  1.26    itojun #include <netinet6/in6_var.h>
    106  1.29    itojun #include <netinet/ip6.h>
    107  1.26    itojun #endif
    108  1.26    itojun 
    109   1.1       cgd 
    110  1.22  christos #ifdef IPX
    111  1.22  christos #include <netipx/ipx.h>
    112  1.22  christos #include <netipx/ipx_if.h>
    113  1.22  christos #endif
    114  1.22  christos 
    115   1.1       cgd #ifdef ISO
    116   1.9   mycroft #include <netiso/iso.h>
    117   1.9   mycroft #include <netiso/iso_var.h>
    118   1.1       cgd #endif
    119   1.1       cgd 
    120  1.19  christos #ifdef NETATALK
    121  1.19  christos #include <netatalk/at.h>
    122  1.19  christos #include <netatalk/at_var.h>
    123  1.19  christos #endif
    124  1.19  christos 
    125   1.2       cgd #if NBPFILTER > 0
    126   1.2       cgd #include <net/bpf.h>
    127   1.2       cgd #endif
    128   1.9   mycroft 
    129  1.26    itojun #if defined(LARGE_LOMTU)
    130  1.26    itojun #define LOMTU	(131072 +  MHLEN + MLEN)
    131  1.48  jonathan #define LOMTU_MAX LOMTU
    132  1.26    itojun #else
    133  1.20  jonathan #define	LOMTU	(32768 +  MHLEN + MLEN)
    134  1.48  jonathan #define	LOMTU_MAX	(65536 +  MHLEN + MLEN)
    135  1.26    itojun #endif
    136   1.1       cgd 
    137  1.34   thorpej #ifdef ALTQ
    138  1.57   thorpej static void	lostart(struct ifnet *);
    139  1.34   thorpej #endif
    140  1.32   thorpej 
    141  1.57   thorpej static int	loop_clone_create(struct if_clone *, int);
    142  1.57   thorpej static int	loop_clone_destroy(struct ifnet *);
    143  1.52     peter 
    144  1.57   thorpej static struct if_clone loop_cloner =
    145  1.52     peter     IF_CLONE_INITIALIZER("lo", loop_clone_create, loop_clone_destroy);
    146  1.52     peter 
    147   1.6    andrew void
    148  1.62  christos loopattach(int n)
    149   1.1       cgd {
    150  1.52     peter 
    151  1.52     peter 	(void)loop_clone_create(&loop_cloner, 0);	/* lo0 always exists */
    152  1.52     peter 	if_clone_attach(&loop_cloner);
    153  1.52     peter }
    154  1.52     peter 
    155  1.57   thorpej static int
    156  1.52     peter loop_clone_create(struct if_clone *ifc, int unit)
    157  1.52     peter {
    158  1.60     peter 	struct ifnet *ifp;
    159  1.52     peter 
    160  1.60     peter 	ifp = malloc(sizeof(*ifp), M_DEVBUF, M_WAITOK | M_ZERO);
    161  1.52     peter 
    162  1.60     peter 	snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d",
    163  1.52     peter 	    ifc->ifc_name, unit);
    164   1.1       cgd 
    165  1.60     peter 	ifp->if_mtu = LOMTU;
    166  1.60     peter 	ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST | IFF_RUNNING;
    167  1.60     peter 	ifp->if_ioctl = loioctl;
    168  1.60     peter 	ifp->if_output = looutput;
    169  1.34   thorpej #ifdef ALTQ
    170  1.60     peter 	ifp->if_start = lostart;
    171  1.34   thorpej #endif
    172  1.60     peter 	ifp->if_type = IFT_LOOP;
    173  1.60     peter 	ifp->if_hdrlen = 0;
    174  1.60     peter 	ifp->if_addrlen = 0;
    175  1.60     peter 	ifp->if_dlt = DLT_NULL;
    176  1.60     peter 	IFQ_SET_READY(&ifp->if_snd);
    177  1.52     peter 	if (unit == 0)
    178  1.60     peter 		lo0ifp = ifp;
    179  1.60     peter 	if_attach(ifp);
    180  1.60     peter 	if_alloc_sadl(ifp);
    181   1.2       cgd #if NBPFILTER > 0
    182  1.60     peter 	bpfattach(ifp, DLT_NULL, sizeof(u_int));
    183   1.2       cgd #endif
    184  1.42      matt #ifdef MBUFTRACE
    185  1.60     peter 	ifp->if_mowner = malloc(sizeof(struct mowner), M_DEVBUF,
    186  1.52     peter 	    M_WAITOK | M_ZERO);
    187  1.60     peter 	strlcpy(ifp->if_mowner->mo_name, ifp->if_xname,
    188  1.60     peter 	    sizeof(ifp->if_mowner->mo_name));
    189  1.60     peter 	MOWNER_ATTACH(ifp->if_mowner);
    190  1.42      matt #endif
    191  1.52     peter 
    192  1.52     peter 	return (0);
    193  1.52     peter }
    194  1.52     peter 
    195  1.57   thorpej static int
    196  1.52     peter loop_clone_destroy(struct ifnet *ifp)
    197  1.52     peter {
    198  1.52     peter 
    199  1.53     peter 	if (ifp == lo0ifp)
    200  1.53     peter 		return (EPERM);
    201  1.52     peter 
    202  1.52     peter #ifdef MBUFTRACE
    203  1.52     peter 	MOWNER_DETACH(ifp->if_mowner);
    204  1.52     peter 	free(ifp->if_mowner, M_DEVBUF);
    205  1.52     peter #endif
    206  1.52     peter 
    207  1.52     peter #if NBPFILTER > 0
    208  1.52     peter 	bpfdetach(ifp);
    209  1.52     peter #endif
    210  1.52     peter 	if_detach(ifp);
    211  1.52     peter 
    212  1.60     peter 	free(ifp, M_DEVBUF);
    213  1.53     peter 
    214  1.53     peter 	return (0);
    215   1.1       cgd }
    216   1.1       cgd 
    217  1.11   mycroft int
    218  1.54     peter looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
    219  1.54     peter     struct rtentry *rt)
    220   1.1       cgd {
    221   1.1       cgd 	int s, isr;
    222  1.54     peter 	struct ifqueue *ifq = NULL;
    223   1.1       cgd 
    224  1.42      matt 	MCLAIM(m, ifp->if_mowner);
    225   1.1       cgd 	if ((m->m_flags & M_PKTHDR) == 0)
    226  1.14   mycroft 		panic("looutput: no header mbuf");
    227   1.2       cgd #if NBPFILTER > 0
    228  1.51  christos 	if (ifp->if_bpf && (ifp->if_flags & IFF_LOOPBACK))
    229  1.51  christos 		bpf_mtap_af(ifp->if_bpf, dst->sa_family, m);
    230   1.2       cgd #endif
    231   1.1       cgd 	m->m_pkthdr.rcvif = ifp;
    232   1.1       cgd 
    233  1.11   mycroft 	if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
    234   1.1       cgd 		m_freem(m);
    235  1.11   mycroft 		return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
    236  1.11   mycroft 			rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
    237   1.1       cgd 	}
    238  1.26    itojun 
    239   1.1       cgd 	ifp->if_opackets++;
    240   1.1       cgd 	ifp->if_obytes += m->m_pkthdr.len;
    241  1.32   thorpej 
    242  1.32   thorpej #ifdef ALTQ
    243  1.32   thorpej 	/*
    244  1.32   thorpej 	 * ALTQ on the loopback interface is just for debugging.  It's
    245  1.32   thorpej 	 * used only for loopback interfaces, not for a simplex interface.
    246  1.32   thorpej 	 */
    247  1.32   thorpej 	if ((ALTQ_IS_ENABLED(&ifp->if_snd) || TBR_IS_ENABLED(&ifp->if_snd)) &&
    248  1.32   thorpej 	    ifp->if_start == lostart) {
    249  1.32   thorpej 		struct altq_pktattr pktattr;
    250  1.32   thorpej 		int error;
    251  1.32   thorpej 
    252  1.32   thorpej 		/*
    253  1.32   thorpej 		 * If the queueing discipline needs packet classification,
    254  1.32   thorpej 		 * do it before prepending the link headers.
    255  1.32   thorpej 		 */
    256  1.32   thorpej 		IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr);
    257  1.32   thorpej 
    258  1.32   thorpej 		M_PREPEND(m, sizeof(uint32_t), M_DONTWAIT);
    259  1.32   thorpej 		if (m == NULL)
    260  1.32   thorpej 			return (ENOBUFS);
    261  1.32   thorpej 		*(mtod(m, uint32_t *)) = dst->sa_family;
    262  1.32   thorpej 
    263  1.38   thorpej 		s = splnet();
    264  1.32   thorpej 		IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error);
    265  1.32   thorpej 		(*ifp->if_start)(ifp);
    266  1.32   thorpej 		splx(s);
    267  1.32   thorpej 		return (error);
    268  1.32   thorpej 	}
    269  1.32   thorpej #endif /* ALTQ */
    270  1.49  jonathan 
    271  1.49  jonathan 	m_tag_delete_nonpersistent(m);
    272  1.32   thorpej 
    273   1.1       cgd 	switch (dst->sa_family) {
    274   1.1       cgd 
    275   1.1       cgd #ifdef INET
    276   1.1       cgd 	case AF_INET:
    277   1.1       cgd 		ifq = &ipintrq;
    278   1.1       cgd 		isr = NETISR_IP;
    279   1.1       cgd 		break;
    280   1.1       cgd #endif
    281  1.26    itojun #ifdef INET6
    282  1.26    itojun 	case AF_INET6:
    283  1.26    itojun 		m->m_flags |= M_LOOP;
    284  1.26    itojun 		ifq = &ip6intrq;
    285  1.26    itojun 		isr = NETISR_IPV6;
    286  1.26    itojun 		break;
    287  1.26    itojun #endif
    288   1.1       cgd #ifdef ISO
    289   1.1       cgd 	case AF_ISO:
    290   1.1       cgd 		ifq = &clnlintrq;
    291   1.1       cgd 		isr = NETISR_ISO;
    292  1.22  christos 		break;
    293  1.22  christos #endif
    294  1.22  christos #ifdef IPX
    295  1.22  christos 	case AF_IPX:
    296  1.22  christos 		ifq = &ipxintrq;
    297  1.22  christos 		isr = NETISR_IPX;
    298  1.19  christos 		break;
    299  1.19  christos #endif
    300  1.19  christos #ifdef NETATALK
    301  1.19  christos 	case AF_APPLETALK:
    302  1.19  christos 	        ifq = &atintrq2;
    303  1.19  christos 		isr = NETISR_ATALK;
    304   1.1       cgd 		break;
    305   1.1       cgd #endif
    306   1.1       cgd 	default:
    307  1.17  christos 		printf("%s: can't handle af%d\n", ifp->if_xname,
    308  1.16  christos 		    dst->sa_family);
    309   1.1       cgd 		m_freem(m);
    310   1.1       cgd 		return (EAFNOSUPPORT);
    311   1.1       cgd 	}
    312  1.38   thorpej 	s = splnet();
    313   1.1       cgd 	if (IF_QFULL(ifq)) {
    314   1.1       cgd 		IF_DROP(ifq);
    315   1.1       cgd 		m_freem(m);
    316   1.1       cgd 		splx(s);
    317   1.1       cgd 		return (ENOBUFS);
    318   1.1       cgd 	}
    319   1.1       cgd 	IF_ENQUEUE(ifq, m);
    320   1.1       cgd 	schednetisr(isr);
    321   1.1       cgd 	ifp->if_ipackets++;
    322   1.1       cgd 	ifp->if_ibytes += m->m_pkthdr.len;
    323   1.1       cgd 	splx(s);
    324   1.1       cgd 	return (0);
    325   1.1       cgd }
    326  1.32   thorpej 
    327  1.32   thorpej #ifdef ALTQ
    328  1.57   thorpej static void
    329  1.32   thorpej lostart(struct ifnet *ifp)
    330  1.32   thorpej {
    331  1.32   thorpej 	struct ifqueue *ifq;
    332  1.32   thorpej 	struct mbuf *m;
    333  1.32   thorpej 	uint32_t af;
    334  1.32   thorpej 	int s, isr;
    335  1.32   thorpej 
    336  1.32   thorpej 	for (;;) {
    337  1.32   thorpej 		IFQ_DEQUEUE(&ifp->if_snd, m);
    338  1.32   thorpej 		if (m == NULL)
    339  1.32   thorpej 			return;
    340  1.32   thorpej 
    341  1.32   thorpej 		af = *(mtod(m, uint32_t *));
    342  1.32   thorpej 		m_adj(m, sizeof(uint32_t));
    343  1.32   thorpej 
    344  1.32   thorpej 		switch (af) {
    345  1.32   thorpej #ifdef INET
    346  1.32   thorpej 		case AF_INET:
    347  1.32   thorpej 			ifq = &ipintrq;
    348  1.32   thorpej 			isr = NETISR_IP;
    349  1.32   thorpej 			break;
    350  1.32   thorpej #endif
    351  1.32   thorpej #ifdef INET6
    352  1.32   thorpej 		case AF_INET6:
    353  1.32   thorpej 			m->m_flags |= M_LOOP;
    354  1.32   thorpej 			ifq = &ip6intrq;
    355  1.32   thorpej 			isr = NETISR_IPV6;
    356  1.32   thorpej 			break;
    357  1.32   thorpej #endif
    358  1.32   thorpej #ifdef IPX
    359  1.32   thorpej 		case AF_IPX:
    360  1.32   thorpej 			ifq = &ipxintrq;
    361  1.32   thorpej 			isr = NETISR_IPX;
    362  1.32   thorpej 			break;
    363  1.32   thorpej #endif
    364  1.32   thorpej #ifdef ISO
    365  1.32   thorpej 		case AF_ISO:
    366  1.32   thorpej 			ifq = &clnlintrq;
    367  1.32   thorpej 			isr = NETISR_ISO;
    368  1.32   thorpej 			break;
    369  1.32   thorpej #endif
    370  1.32   thorpej #ifdef NETATALK
    371  1.32   thorpej 		case AF_APPLETALK:
    372  1.32   thorpej 			ifq = &atintrq2;
    373  1.32   thorpej 			isr = NETISR_ATALK;
    374  1.32   thorpej 			break;
    375  1.32   thorpej #endif
    376  1.32   thorpej 		default:
    377  1.32   thorpej 			printf("%s: can't handle af%d\n", ifp->if_xname, af);
    378  1.32   thorpej 			m_freem(m);
    379  1.32   thorpej 			return;
    380  1.32   thorpej 		}
    381  1.32   thorpej 
    382  1.38   thorpej 		s = splnet();
    383  1.32   thorpej 		if (IF_QFULL(ifq)) {
    384  1.32   thorpej 			IF_DROP(ifq);
    385  1.32   thorpej 			splx(s);
    386  1.32   thorpej 			m_freem(m);
    387  1.32   thorpej 			return;
    388  1.32   thorpej 		}
    389  1.32   thorpej 		IF_ENQUEUE(ifq, m);
    390  1.32   thorpej 		schednetisr(isr);
    391  1.32   thorpej 		ifp->if_ipackets++;
    392  1.32   thorpej 		ifp->if_ibytes += m->m_pkthdr.len;
    393  1.32   thorpej 		splx(s);
    394  1.32   thorpej 	}
    395  1.32   thorpej }
    396  1.32   thorpej #endif /* ALTQ */
    397   1.1       cgd 
    398   1.1       cgd /* ARGSUSED */
    399  1.11   mycroft void
    400  1.62  christos lortrequest(int cmd, struct rtentry *rt,
    401  1.62  christos     struct rt_addrinfo *info)
    402   1.1       cgd {
    403  1.11   mycroft 
    404   1.1       cgd 	if (rt)
    405  1.52     peter 		rt->rt_rmx.rmx_mtu = lo0ifp->if_mtu;
    406   1.1       cgd }
    407   1.1       cgd 
    408   1.1       cgd /*
    409   1.1       cgd  * Process an ioctl request.
    410   1.1       cgd  */
    411   1.1       cgd /* ARGSUSED */
    412  1.11   mycroft int
    413  1.54     peter loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
    414   1.1       cgd {
    415  1.30  augustss 	struct ifaddr *ifa;
    416  1.30  augustss 	struct ifreq *ifr;
    417  1.30  augustss 	int error = 0;
    418   1.1       cgd 
    419   1.1       cgd 	switch (cmd) {
    420   1.1       cgd 
    421   1.1       cgd 	case SIOCSIFADDR:
    422   1.1       cgd 		ifp->if_flags |= IFF_UP;
    423   1.1       cgd 		ifa = (struct ifaddr *)data;
    424  1.54     peter 		if (ifa != NULL /*&& ifa->ifa_addr->sa_family == AF_ISO*/)
    425   1.1       cgd 			ifa->ifa_rtrequest = lortrequest;
    426   1.1       cgd 		/*
    427   1.1       cgd 		 * Everything else is done at a higher level.
    428   1.1       cgd 		 */
    429  1.48  jonathan 		break;
    430  1.48  jonathan 
    431  1.48  jonathan 	case SIOCSIFMTU:
    432  1.48  jonathan 		ifr = (struct ifreq *)data;
    433  1.48  jonathan 		if ((unsigned)ifr->ifr_mtu > LOMTU_MAX)
    434  1.48  jonathan 			error = EINVAL;
    435  1.48  jonathan 		else {
    436  1.48  jonathan 			/* XXX update rt mtu for AF_ISO? */
    437  1.48  jonathan 			ifp->if_mtu = ifr->ifr_mtu;
    438  1.48  jonathan 		}
    439   1.1       cgd 		break;
    440   1.1       cgd 
    441   1.8   hpeyerl 	case SIOCADDMULTI:
    442   1.8   hpeyerl 	case SIOCDELMULTI:
    443   1.8   hpeyerl 		ifr = (struct ifreq *)data;
    444  1.54     peter 		if (ifr == NULL) {
    445   1.8   hpeyerl 			error = EAFNOSUPPORT;		/* XXX */
    446   1.8   hpeyerl 			break;
    447   1.8   hpeyerl 		}
    448   1.8   hpeyerl 		switch (ifr->ifr_addr.sa_family) {
    449   1.8   hpeyerl 
    450   1.8   hpeyerl #ifdef INET
    451   1.8   hpeyerl 		case AF_INET:
    452  1.26    itojun 			break;
    453  1.26    itojun #endif
    454  1.26    itojun #ifdef INET6
    455  1.26    itojun 		case AF_INET6:
    456   1.8   hpeyerl 			break;
    457   1.8   hpeyerl #endif
    458  1.11   mycroft 
    459   1.8   hpeyerl 		default:
    460   1.8   hpeyerl 			error = EAFNOSUPPORT;
    461   1.8   hpeyerl 			break;
    462   1.8   hpeyerl 		}
    463   1.8   hpeyerl 		break;
    464  1.11   mycroft 
    465   1.1       cgd 	default:
    466   1.1       cgd 		error = EINVAL;
    467   1.1       cgd 	}
    468   1.1       cgd 	return (error);
    469   1.1       cgd }
    470