Home | History | Annotate | Line # | Download | only in net
if_loop.c revision 1.32
      1  1.32   thorpej /*	$NetBSD: if_loop.c,v 1.32 2000/12/18 19:18:33 thorpej 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.26    itojun  *
      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.26    itojun  *
     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.1       cgd  * 3. All advertising materials mentioning features or use of this software
     45   1.1       cgd  *    must display the following acknowledgement:
     46   1.1       cgd  *	This product includes software developed by the University of
     47   1.1       cgd  *	California, Berkeley and its contributors.
     48   1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     49   1.1       cgd  *    may be used to endorse or promote products derived from this software
     50   1.1       cgd  *    without specific prior written permission.
     51   1.1       cgd  *
     52   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     53   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     56   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62   1.1       cgd  * SUCH DAMAGE.
     63   1.1       cgd  *
     64  1.21      fvdl  *	@(#)if_loop.c	8.2 (Berkeley) 1/9/95
     65   1.1       cgd  */
     66   1.1       cgd 
     67   1.1       cgd /*
     68   1.1       cgd  * Loopback interface driver for protocol testing and timing.
     69   1.1       cgd  */
     70  1.23  jonathan 
     71  1.23  jonathan #include "opt_inet.h"
     72  1.23  jonathan #include "opt_atalk.h"
     73  1.24  jonathan #include "opt_iso.h"
     74  1.25  jonathan #include "opt_ns.h"
     75   1.1       cgd 
     76   1.9   mycroft #include "bpfilter.h"
     77   1.4       cgd #include "loop.h"
     78   1.4       cgd 
     79   1.9   mycroft #include <sys/param.h>
     80   1.9   mycroft #include <sys/systm.h>
     81  1.11   mycroft #include <sys/kernel.h>
     82   1.9   mycroft #include <sys/mbuf.h>
     83   1.9   mycroft #include <sys/socket.h>
     84   1.9   mycroft #include <sys/errno.h>
     85   1.9   mycroft #include <sys/ioctl.h>
     86  1.11   mycroft #include <sys/time.h>
     87  1.11   mycroft 
     88  1.11   mycroft #include <machine/cpu.h>
     89   1.9   mycroft 
     90   1.9   mycroft #include <net/if.h>
     91   1.9   mycroft #include <net/if_types.h>
     92   1.9   mycroft #include <net/netisr.h>
     93   1.9   mycroft #include <net/route.h>
     94   1.1       cgd 
     95   1.1       cgd #ifdef	INET
     96   1.9   mycroft #include <netinet/in.h>
     97   1.9   mycroft #include <netinet/in_systm.h>
     98   1.9   mycroft #include <netinet/in_var.h>
     99   1.9   mycroft #include <netinet/ip.h>
    100   1.1       cgd #endif
    101   1.1       cgd 
    102  1.26    itojun #ifdef INET6
    103  1.26    itojun #ifndef INET
    104  1.26    itojun #include <netinet/in.h>
    105  1.26    itojun #endif
    106  1.26    itojun #include <netinet6/in6_var.h>
    107  1.29    itojun #include <netinet/ip6.h>
    108  1.26    itojun #endif
    109  1.26    itojun 
    110   1.1       cgd #ifdef NS
    111   1.9   mycroft #include <netns/ns.h>
    112   1.9   mycroft #include <netns/ns_if.h>
    113   1.1       cgd #endif
    114   1.1       cgd 
    115  1.22  christos #ifdef IPX
    116  1.22  christos #include <netipx/ipx.h>
    117  1.22  christos #include <netipx/ipx_if.h>
    118  1.22  christos #endif
    119  1.22  christos 
    120   1.1       cgd #ifdef ISO
    121   1.9   mycroft #include <netiso/iso.h>
    122   1.9   mycroft #include <netiso/iso_var.h>
    123   1.1       cgd #endif
    124   1.1       cgd 
    125  1.19  christos #ifdef NETATALK
    126  1.19  christos #include <netatalk/at.h>
    127  1.19  christos #include <netatalk/at_var.h>
    128  1.19  christos #endif
    129  1.19  christos 
    130   1.2       cgd #if NBPFILTER > 0
    131   1.2       cgd #include <net/bpf.h>
    132   1.2       cgd #endif
    133   1.9   mycroft 
    134  1.26    itojun #if defined(LARGE_LOMTU)
    135  1.26    itojun #define LOMTU	(131072 +  MHLEN + MLEN)
    136  1.26    itojun #else
    137  1.20  jonathan #define	LOMTU	(32768 +  MHLEN + MLEN)
    138  1.26    itojun #endif
    139   1.1       cgd 
    140   1.4       cgd struct	ifnet loif[NLOOP];
    141   1.1       cgd 
    142  1.32   thorpej void	lostart(struct ifnet *);
    143  1.32   thorpej 
    144   1.6    andrew void
    145  1.11   mycroft loopattach(n)
    146  1.11   mycroft 	int n;
    147   1.1       cgd {
    148  1.30  augustss 	int i;
    149  1.30  augustss 	struct ifnet *ifp;
    150   1.1       cgd 
    151  1.11   mycroft 	for (i = 0; i < NLOOP; i++) {
    152   1.4       cgd 		ifp = &loif[i];
    153  1.17  christos 		sprintf(ifp->if_xname, "lo%d", i);
    154  1.15   thorpej 		ifp->if_softc = NULL;
    155   1.4       cgd 		ifp->if_mtu = LOMTU;
    156  1.11   mycroft 		ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
    157   1.4       cgd 		ifp->if_ioctl = loioctl;
    158   1.4       cgd 		ifp->if_output = looutput;
    159  1.32   thorpej 		ifp->if_start = lostart;
    160   1.4       cgd 		ifp->if_type = IFT_LOOP;
    161   1.4       cgd 		ifp->if_hdrlen = 0;
    162   1.4       cgd 		ifp->if_addrlen = 0;
    163  1.32   thorpej 		IFQ_SET_READY(&ifp->if_snd);
    164   1.4       cgd 		if_attach(ifp);
    165   1.2       cgd #if NBPFILTER > 0
    166  1.31   thorpej 		bpfattach(ifp, DLT_NULL, sizeof(u_int));
    167   1.2       cgd #endif
    168   1.4       cgd 	}
    169   1.1       cgd }
    170   1.1       cgd 
    171  1.11   mycroft int
    172   1.1       cgd looutput(ifp, m, dst, rt)
    173   1.1       cgd 	struct ifnet *ifp;
    174  1.30  augustss 	struct mbuf *m;
    175   1.1       cgd 	struct sockaddr *dst;
    176  1.30  augustss 	struct rtentry *rt;
    177   1.1       cgd {
    178   1.1       cgd 	int s, isr;
    179  1.30  augustss 	struct ifqueue *ifq = 0;
    180   1.1       cgd 
    181   1.1       cgd 	if ((m->m_flags & M_PKTHDR) == 0)
    182  1.14   mycroft 		panic("looutput: no header mbuf");
    183  1.11   mycroft 	ifp->if_lastchange = time;
    184   1.2       cgd #if NBPFILTER > 0
    185  1.18   mycroft 	if (ifp->if_bpf && (ifp->if_flags & IFF_LOOPBACK)) {
    186   1.2       cgd 		/*
    187   1.2       cgd 		 * We need to prepend the address family as
    188   1.2       cgd 		 * a four byte field.  Cons up a dummy header
    189   1.2       cgd 		 * to pacify bpf.  This is safe because bpf
    190   1.2       cgd 		 * will only read from the mbuf (i.e., it won't
    191   1.2       cgd 		 * try to free it or keep a pointer to it).
    192   1.2       cgd 		 */
    193   1.2       cgd 		struct mbuf m0;
    194   1.2       cgd 		u_int af = dst->sa_family;
    195   1.2       cgd 
    196   1.2       cgd 		m0.m_next = m;
    197   1.2       cgd 		m0.m_len = 4;
    198   1.2       cgd 		m0.m_data = (char *)&af;
    199   1.2       cgd 
    200  1.11   mycroft 		bpf_mtap(ifp->if_bpf, &m0);
    201   1.2       cgd 	}
    202   1.2       cgd #endif
    203   1.1       cgd 	m->m_pkthdr.rcvif = ifp;
    204   1.1       cgd 
    205  1.11   mycroft 	if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
    206   1.1       cgd 		m_freem(m);
    207  1.11   mycroft 		return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
    208  1.11   mycroft 			rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
    209   1.1       cgd 	}
    210  1.26    itojun 
    211  1.27    itojun #ifndef PULLDOWN_TEST
    212  1.26    itojun 	/*
    213  1.26    itojun 	 * KAME requires that the packet to be contiguous on the
    214  1.26    itojun 	 * mbuf.  We need to make that sure.
    215  1.26    itojun 	 * this kind of code should be avoided.
    216  1.27    itojun 	 * XXX other conditions to avoid running this part?
    217  1.26    itojun 	 */
    218  1.28    itojun 	if (m->m_len != m->m_pkthdr.len) {
    219  1.28    itojun 		struct mbuf *n = NULL;
    220  1.28    itojun 		int maxlen;
    221  1.26    itojun 
    222  1.26    itojun 		MGETHDR(n, M_DONTWAIT, MT_HEADER);
    223  1.28    itojun 		maxlen = MHLEN;
    224  1.28    itojun 		if (n)
    225  1.28    itojun 			M_COPY_PKTHDR(n, m);
    226  1.28    itojun 		if (n && m->m_pkthdr.len > maxlen) {
    227  1.27    itojun 			MCLGET(n, M_DONTWAIT);
    228  1.28    itojun 			maxlen = MCLBYTES;
    229  1.27    itojun 			if ((n->m_flags & M_EXT) == 0) {
    230  1.27    itojun 				m_free(n);
    231  1.27    itojun 				n = NULL;
    232  1.27    itojun 			}
    233  1.27    itojun 		}
    234  1.27    itojun 		if (!n) {
    235  1.27    itojun 			printf("looutput: mbuf allocation failed\n");
    236  1.27    itojun 			m_freem(m);
    237  1.27    itojun 			return ENOBUFS;
    238  1.26    itojun 		}
    239  1.26    itojun 
    240  1.28    itojun 		if (m->m_pkthdr.len <= maxlen) {
    241  1.27    itojun 			m_copydata(m, 0, m->m_pkthdr.len, mtod(n, caddr_t));
    242  1.27    itojun 			n->m_len = m->m_pkthdr.len;
    243  1.27    itojun 			n->m_next = NULL;
    244  1.27    itojun 			m_freem(m);
    245  1.27    itojun 		} else {
    246  1.28    itojun 			m_copydata(m, 0, maxlen, mtod(n, caddr_t));
    247  1.28    itojun 			m_adj(m, maxlen);
    248  1.28    itojun 			n->m_len = maxlen;
    249  1.27    itojun 			n->m_next = m;
    250  1.27    itojun 			m->m_flags &= ~M_PKTHDR;
    251  1.27    itojun 		}
    252  1.26    itojun 		m = n;
    253  1.26    itojun 	}
    254  1.26    itojun #if 0
    255  1.27    itojun 	if (m && m->m_next != NULL) {
    256  1.26    itojun 		printf("loop: not contiguous...\n");
    257  1.27    itojun 		m_freem(m);
    258  1.27    itojun 		return ENOBUFS;
    259  1.27    itojun 	}
    260  1.26    itojun #endif
    261  1.26    itojun #endif
    262  1.26    itojun 
    263   1.1       cgd 	ifp->if_opackets++;
    264   1.1       cgd 	ifp->if_obytes += m->m_pkthdr.len;
    265  1.32   thorpej 
    266  1.32   thorpej #ifdef ALTQ
    267  1.32   thorpej 	/*
    268  1.32   thorpej 	 * ALTQ on the loopback interface is just for debugging.  It's
    269  1.32   thorpej 	 * used only for loopback interfaces, not for a simplex interface.
    270  1.32   thorpej 	 */
    271  1.32   thorpej 	if ((ALTQ_IS_ENABLED(&ifp->if_snd) || TBR_IS_ENABLED(&ifp->if_snd)) &&
    272  1.32   thorpej 	    ifp->if_start == lostart) {
    273  1.32   thorpej 		struct altq_pktattr pktattr;
    274  1.32   thorpej 		int error;
    275  1.32   thorpej 
    276  1.32   thorpej 		/*
    277  1.32   thorpej 		 * If the queueing discipline needs packet classification,
    278  1.32   thorpej 		 * do it before prepending the link headers.
    279  1.32   thorpej 		 */
    280  1.32   thorpej 		IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr);
    281  1.32   thorpej 
    282  1.32   thorpej 		M_PREPEND(m, sizeof(uint32_t), M_DONTWAIT);
    283  1.32   thorpej 		if (m == NULL)
    284  1.32   thorpej 			return (ENOBUFS);
    285  1.32   thorpej 		*(mtod(m, uint32_t *)) = dst->sa_family;
    286  1.32   thorpej 
    287  1.32   thorpej 		s = splimp();
    288  1.32   thorpej 		IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error);
    289  1.32   thorpej 		(*ifp->if_start)(ifp);
    290  1.32   thorpej 		splx(s);
    291  1.32   thorpej 		return (error);
    292  1.32   thorpej 	}
    293  1.32   thorpej #endif /* ALTQ */
    294  1.32   thorpej 
    295   1.1       cgd 	switch (dst->sa_family) {
    296   1.1       cgd 
    297   1.1       cgd #ifdef INET
    298   1.1       cgd 	case AF_INET:
    299   1.1       cgd 		ifq = &ipintrq;
    300   1.1       cgd 		isr = NETISR_IP;
    301   1.1       cgd 		break;
    302   1.1       cgd #endif
    303  1.26    itojun #ifdef INET6
    304  1.26    itojun 	case AF_INET6:
    305  1.26    itojun 		m->m_flags |= M_LOOP;
    306  1.26    itojun 		ifq = &ip6intrq;
    307  1.26    itojun 		isr = NETISR_IPV6;
    308  1.26    itojun 		break;
    309  1.26    itojun #endif
    310   1.1       cgd #ifdef NS
    311   1.1       cgd 	case AF_NS:
    312   1.1       cgd 		ifq = &nsintrq;
    313   1.1       cgd 		isr = NETISR_NS;
    314   1.1       cgd 		break;
    315   1.1       cgd #endif
    316   1.1       cgd #ifdef ISO
    317   1.1       cgd 	case AF_ISO:
    318   1.1       cgd 		ifq = &clnlintrq;
    319   1.1       cgd 		isr = NETISR_ISO;
    320  1.22  christos 		break;
    321  1.22  christos #endif
    322  1.22  christos #ifdef IPX
    323  1.22  christos 	case AF_IPX:
    324  1.22  christos 		ifq = &ipxintrq;
    325  1.22  christos 		isr = NETISR_IPX;
    326  1.19  christos 		break;
    327  1.19  christos #endif
    328  1.19  christos #ifdef NETATALK
    329  1.19  christos 	case AF_APPLETALK:
    330  1.19  christos 	        ifq = &atintrq2;
    331  1.19  christos 		isr = NETISR_ATALK;
    332   1.1       cgd 		break;
    333   1.1       cgd #endif
    334   1.1       cgd 	default:
    335  1.17  christos 		printf("%s: can't handle af%d\n", ifp->if_xname,
    336  1.16  christos 		    dst->sa_family);
    337   1.1       cgd 		m_freem(m);
    338   1.1       cgd 		return (EAFNOSUPPORT);
    339   1.1       cgd 	}
    340   1.1       cgd 	s = splimp();
    341   1.1       cgd 	if (IF_QFULL(ifq)) {
    342   1.1       cgd 		IF_DROP(ifq);
    343   1.1       cgd 		m_freem(m);
    344   1.1       cgd 		splx(s);
    345   1.1       cgd 		return (ENOBUFS);
    346   1.1       cgd 	}
    347   1.1       cgd 	IF_ENQUEUE(ifq, m);
    348   1.1       cgd 	schednetisr(isr);
    349   1.1       cgd 	ifp->if_ipackets++;
    350   1.1       cgd 	ifp->if_ibytes += m->m_pkthdr.len;
    351   1.1       cgd 	splx(s);
    352   1.1       cgd 	return (0);
    353   1.1       cgd }
    354  1.32   thorpej 
    355  1.32   thorpej #ifdef ALTQ
    356  1.32   thorpej void
    357  1.32   thorpej lostart(struct ifnet *ifp)
    358  1.32   thorpej {
    359  1.32   thorpej 	struct ifqueue *ifq;
    360  1.32   thorpej 	struct mbuf *m;
    361  1.32   thorpej 	uint32_t af;
    362  1.32   thorpej 	int s, isr;
    363  1.32   thorpej 
    364  1.32   thorpej 	for (;;) {
    365  1.32   thorpej 		IFQ_DEQUEUE(&ifp->if_snd, m);
    366  1.32   thorpej 		if (m == NULL)
    367  1.32   thorpej 			return;
    368  1.32   thorpej 
    369  1.32   thorpej 		af = *(mtod(m, uint32_t *));
    370  1.32   thorpej 		m_adj(m, sizeof(uint32_t));
    371  1.32   thorpej 
    372  1.32   thorpej 		switch (af) {
    373  1.32   thorpej #ifdef INET
    374  1.32   thorpej 		case AF_INET:
    375  1.32   thorpej 			ifq = &ipintrq;
    376  1.32   thorpej 			isr = NETISR_IP;
    377  1.32   thorpej 			break;
    378  1.32   thorpej #endif
    379  1.32   thorpej #ifdef INET6
    380  1.32   thorpej 		case AF_INET6:
    381  1.32   thorpej 			m->m_flags |= M_LOOP;
    382  1.32   thorpej 			ifq = &ip6intrq;
    383  1.32   thorpej 			isr = NETISR_IPV6;
    384  1.32   thorpej 			break;
    385  1.32   thorpej #endif
    386  1.32   thorpej #ifdef IPX
    387  1.32   thorpej 		case AF_IPX:
    388  1.32   thorpej 			ifq = &ipxintrq;
    389  1.32   thorpej 			isr = NETISR_IPX;
    390  1.32   thorpej 			break;
    391  1.32   thorpej #endif
    392  1.32   thorpej #ifdef NS
    393  1.32   thorpej 		case AF_NS:
    394  1.32   thorpej 			ifq = &nsintrq;
    395  1.32   thorpej 			isr = NETISR_NS;
    396  1.32   thorpej 			break;
    397  1.32   thorpej #endif
    398  1.32   thorpej #ifdef ISO
    399  1.32   thorpej 		case AF_ISO:
    400  1.32   thorpej 			ifq = &clnlintrq;
    401  1.32   thorpej 			isr = NETISR_ISO;
    402  1.32   thorpej 			break;
    403  1.32   thorpej #endif
    404  1.32   thorpej #ifdef NETATALK
    405  1.32   thorpej 		case AF_APPLETALK:
    406  1.32   thorpej 			ifq = &atintrq2;
    407  1.32   thorpej 			isr = NETISR_ATALK;
    408  1.32   thorpej 			break;
    409  1.32   thorpej #endif
    410  1.32   thorpej 		default:
    411  1.32   thorpej 			printf("%s: can't handle af%d\n", ifp->if_xname, af);
    412  1.32   thorpej 			m_freem(m);
    413  1.32   thorpej 			return;
    414  1.32   thorpej 		}
    415  1.32   thorpej 
    416  1.32   thorpej 		s = splimp();
    417  1.32   thorpej 		if (IF_QFULL(ifq)) {
    418  1.32   thorpej 			IF_DROP(ifq);
    419  1.32   thorpej 			splx(s);
    420  1.32   thorpej 			m_freem(m);
    421  1.32   thorpej 			return;
    422  1.32   thorpej 		}
    423  1.32   thorpej 		IF_ENQUEUE(ifq, m);
    424  1.32   thorpej 		schednetisr(isr);
    425  1.32   thorpej 		ifp->if_ipackets++;
    426  1.32   thorpej 		ifp->if_ibytes += m->m_pkthdr.len;
    427  1.32   thorpej 		splx(s);
    428  1.32   thorpej 	}
    429  1.32   thorpej }
    430  1.32   thorpej #endif /* ALTQ */
    431   1.1       cgd 
    432   1.1       cgd /* ARGSUSED */
    433  1.11   mycroft void
    434   1.1       cgd lortrequest(cmd, rt, sa)
    435  1.11   mycroft 	int cmd;
    436  1.11   mycroft 	struct rtentry *rt;
    437  1.11   mycroft 	struct sockaddr *sa;
    438   1.1       cgd {
    439  1.11   mycroft 
    440   1.1       cgd 	if (rt)
    441   1.1       cgd 		rt->rt_rmx.rmx_mtu = LOMTU;
    442   1.1       cgd }
    443   1.1       cgd 
    444   1.1       cgd /*
    445   1.1       cgd  * Process an ioctl request.
    446   1.1       cgd  */
    447   1.1       cgd /* ARGSUSED */
    448  1.11   mycroft int
    449   1.1       cgd loioctl(ifp, cmd, data)
    450  1.30  augustss 	struct ifnet *ifp;
    451  1.13       cgd 	u_long cmd;
    452   1.1       cgd 	caddr_t data;
    453   1.1       cgd {
    454  1.30  augustss 	struct ifaddr *ifa;
    455  1.30  augustss 	struct ifreq *ifr;
    456  1.30  augustss 	int error = 0;
    457   1.1       cgd 
    458   1.1       cgd 	switch (cmd) {
    459   1.1       cgd 
    460   1.1       cgd 	case SIOCSIFADDR:
    461   1.1       cgd 		ifp->if_flags |= IFF_UP;
    462   1.1       cgd 		ifa = (struct ifaddr *)data;
    463  1.26    itojun 		if (ifa != 0 /*&& ifa->ifa_addr->sa_family == AF_ISO*/)
    464   1.1       cgd 			ifa->ifa_rtrequest = lortrequest;
    465   1.1       cgd 		/*
    466   1.1       cgd 		 * Everything else is done at a higher level.
    467   1.1       cgd 		 */
    468   1.1       cgd 		break;
    469   1.1       cgd 
    470   1.8   hpeyerl 	case SIOCADDMULTI:
    471   1.8   hpeyerl 	case SIOCDELMULTI:
    472   1.8   hpeyerl 		ifr = (struct ifreq *)data;
    473   1.8   hpeyerl 		if (ifr == 0) {
    474   1.8   hpeyerl 			error = EAFNOSUPPORT;		/* XXX */
    475   1.8   hpeyerl 			break;
    476   1.8   hpeyerl 		}
    477   1.8   hpeyerl 		switch (ifr->ifr_addr.sa_family) {
    478   1.8   hpeyerl 
    479   1.8   hpeyerl #ifdef INET
    480   1.8   hpeyerl 		case AF_INET:
    481  1.26    itojun 			break;
    482  1.26    itojun #endif
    483  1.26    itojun #ifdef INET6
    484  1.26    itojun 		case AF_INET6:
    485   1.8   hpeyerl 			break;
    486   1.8   hpeyerl #endif
    487  1.11   mycroft 
    488   1.8   hpeyerl 		default:
    489   1.8   hpeyerl 			error = EAFNOSUPPORT;
    490   1.8   hpeyerl 			break;
    491   1.8   hpeyerl 		}
    492   1.8   hpeyerl 		break;
    493  1.11   mycroft 
    494   1.1       cgd 	default:
    495   1.1       cgd 		error = EINVAL;
    496   1.1       cgd 	}
    497   1.1       cgd 	return (error);
    498   1.1       cgd }
    499