if_loop.c revision 1.79 1 1.79 rmind /* $NetBSD: if_loop.c,v 1.79 2014/06/05 23:48:16 rmind 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.79 rmind __KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.79 2014/06/05 23:48:16 rmind Exp $");
69 1.23 jonathan
70 1.23 jonathan #include "opt_inet.h"
71 1.23 jonathan #include "opt_atalk.h"
72 1.46 martin #include "opt_ipx.h"
73 1.46 martin #include "opt_mbuftrace.h"
74 1.74 kefren #include "opt_mpls.h"
75 1.1 cgd
76 1.4 cgd
77 1.9 mycroft #include <sys/param.h>
78 1.9 mycroft #include <sys/systm.h>
79 1.11 mycroft #include <sys/kernel.h>
80 1.9 mycroft #include <sys/mbuf.h>
81 1.9 mycroft #include <sys/socket.h>
82 1.9 mycroft #include <sys/errno.h>
83 1.9 mycroft #include <sys/ioctl.h>
84 1.11 mycroft #include <sys/time.h>
85 1.11 mycroft
86 1.66 ad #include <sys/cpu.h>
87 1.9 mycroft
88 1.9 mycroft #include <net/if.h>
89 1.9 mycroft #include <net/if_types.h>
90 1.9 mycroft #include <net/netisr.h>
91 1.9 mycroft #include <net/route.h>
92 1.1 cgd
93 1.1 cgd #ifdef INET
94 1.9 mycroft #include <netinet/in.h>
95 1.9 mycroft #include <netinet/in_systm.h>
96 1.9 mycroft #include <netinet/in_var.h>
97 1.73 yamt #include <netinet/in_offload.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.73 yamt #include <netinet6/in6_offload.h>
107 1.29 itojun #include <netinet/ip6.h>
108 1.26 itojun #endif
109 1.26 itojun
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.74 kefren #ifdef MPLS
116 1.74 kefren #include <netmpls/mpls.h>
117 1.74 kefren #include <netmpls/mpls_var.h>
118 1.74 kefren #endif
119 1.74 kefren
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 #include <net/bpf.h>
126 1.9 mycroft
127 1.26 itojun #if defined(LARGE_LOMTU)
128 1.26 itojun #define LOMTU (131072 + MHLEN + MLEN)
129 1.48 jonathan #define LOMTU_MAX LOMTU
130 1.26 itojun #else
131 1.20 jonathan #define LOMTU (32768 + MHLEN + MLEN)
132 1.48 jonathan #define LOMTU_MAX (65536 + MHLEN + MLEN)
133 1.26 itojun #endif
134 1.1 cgd
135 1.34 thorpej #ifdef ALTQ
136 1.57 thorpej static void lostart(struct ifnet *);
137 1.34 thorpej #endif
138 1.32 thorpej
139 1.57 thorpej static int loop_clone_create(struct if_clone *, int);
140 1.57 thorpej static int loop_clone_destroy(struct ifnet *);
141 1.52 peter
142 1.57 thorpej static struct if_clone loop_cloner =
143 1.52 peter IF_CLONE_INITIALIZER("lo", loop_clone_create, loop_clone_destroy);
144 1.52 peter
145 1.6 andrew void
146 1.62 christos loopattach(int n)
147 1.1 cgd {
148 1.52 peter
149 1.52 peter (void)loop_clone_create(&loop_cloner, 0); /* lo0 always exists */
150 1.52 peter if_clone_attach(&loop_cloner);
151 1.52 peter }
152 1.52 peter
153 1.57 thorpej static int
154 1.52 peter loop_clone_create(struct if_clone *ifc, int unit)
155 1.52 peter {
156 1.60 peter struct ifnet *ifp;
157 1.52 peter
158 1.68 christos ifp = if_alloc(IFT_LOOP);
159 1.52 peter
160 1.68 christos if_initname(ifp, ifc->ifc_name, unit);
161 1.1 cgd
162 1.60 peter ifp->if_mtu = LOMTU;
163 1.60 peter ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST | IFF_RUNNING;
164 1.60 peter ifp->if_ioctl = loioctl;
165 1.60 peter ifp->if_output = looutput;
166 1.34 thorpej #ifdef ALTQ
167 1.60 peter ifp->if_start = lostart;
168 1.34 thorpej #endif
169 1.60 peter ifp->if_type = IFT_LOOP;
170 1.60 peter ifp->if_hdrlen = 0;
171 1.60 peter ifp->if_addrlen = 0;
172 1.60 peter ifp->if_dlt = DLT_NULL;
173 1.60 peter IFQ_SET_READY(&ifp->if_snd);
174 1.52 peter if (unit == 0)
175 1.60 peter lo0ifp = ifp;
176 1.60 peter if_attach(ifp);
177 1.60 peter if_alloc_sadl(ifp);
178 1.72 joerg bpf_attach(ifp, DLT_NULL, sizeof(u_int));
179 1.42 matt #ifdef MBUFTRACE
180 1.60 peter ifp->if_mowner = malloc(sizeof(struct mowner), M_DEVBUF,
181 1.52 peter M_WAITOK | M_ZERO);
182 1.60 peter strlcpy(ifp->if_mowner->mo_name, ifp->if_xname,
183 1.60 peter sizeof(ifp->if_mowner->mo_name));
184 1.60 peter MOWNER_ATTACH(ifp->if_mowner);
185 1.42 matt #endif
186 1.52 peter
187 1.52 peter return (0);
188 1.52 peter }
189 1.52 peter
190 1.57 thorpej static int
191 1.52 peter loop_clone_destroy(struct ifnet *ifp)
192 1.52 peter {
193 1.52 peter
194 1.53 peter if (ifp == lo0ifp)
195 1.53 peter return (EPERM);
196 1.52 peter
197 1.52 peter #ifdef MBUFTRACE
198 1.52 peter MOWNER_DETACH(ifp->if_mowner);
199 1.52 peter free(ifp->if_mowner, M_DEVBUF);
200 1.52 peter #endif
201 1.52 peter
202 1.72 joerg bpf_detach(ifp);
203 1.52 peter if_detach(ifp);
204 1.52 peter
205 1.78 pooka if_free(ifp);
206 1.53 peter
207 1.53 peter return (0);
208 1.1 cgd }
209 1.1 cgd
210 1.11 mycroft int
211 1.63 dyoung looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
212 1.54 peter struct rtentry *rt)
213 1.1 cgd {
214 1.79 rmind pktqueue_t *pktq = NULL;
215 1.79 rmind struct ifqueue *ifq = NULL;
216 1.75 kefren int s, isr = -1;
217 1.73 yamt int csum_flags;
218 1.79 rmind size_t pktlen;
219 1.1 cgd
220 1.42 matt MCLAIM(m, ifp->if_mowner);
221 1.77 bouyer KASSERT(KERNEL_LOCKED_P());
222 1.77 bouyer
223 1.1 cgd if ((m->m_flags & M_PKTHDR) == 0)
224 1.14 mycroft panic("looutput: no header mbuf");
225 1.72 joerg if (ifp->if_flags & IFF_LOOPBACK)
226 1.72 joerg bpf_mtap_af(ifp, dst->sa_family, m);
227 1.1 cgd m->m_pkthdr.rcvif = ifp;
228 1.1 cgd
229 1.11 mycroft if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
230 1.1 cgd m_freem(m);
231 1.11 mycroft return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
232 1.11 mycroft rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
233 1.1 cgd }
234 1.26 itojun
235 1.79 rmind pktlen = m->m_pkthdr.len;
236 1.1 cgd ifp->if_opackets++;
237 1.79 rmind ifp->if_obytes += pktlen;
238 1.32 thorpej
239 1.32 thorpej #ifdef ALTQ
240 1.32 thorpej /*
241 1.32 thorpej * ALTQ on the loopback interface is just for debugging. It's
242 1.32 thorpej * used only for loopback interfaces, not for a simplex interface.
243 1.32 thorpej */
244 1.32 thorpej if ((ALTQ_IS_ENABLED(&ifp->if_snd) || TBR_IS_ENABLED(&ifp->if_snd)) &&
245 1.32 thorpej ifp->if_start == lostart) {
246 1.32 thorpej struct altq_pktattr pktattr;
247 1.32 thorpej int error;
248 1.32 thorpej
249 1.32 thorpej /*
250 1.32 thorpej * If the queueing discipline needs packet classification,
251 1.32 thorpej * do it before prepending the link headers.
252 1.32 thorpej */
253 1.32 thorpej IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr);
254 1.32 thorpej
255 1.32 thorpej M_PREPEND(m, sizeof(uint32_t), M_DONTWAIT);
256 1.32 thorpej if (m == NULL)
257 1.32 thorpej return (ENOBUFS);
258 1.32 thorpej *(mtod(m, uint32_t *)) = dst->sa_family;
259 1.32 thorpej
260 1.38 thorpej s = splnet();
261 1.32 thorpej IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error);
262 1.32 thorpej (*ifp->if_start)(ifp);
263 1.32 thorpej splx(s);
264 1.32 thorpej return (error);
265 1.32 thorpej }
266 1.32 thorpej #endif /* ALTQ */
267 1.49 jonathan
268 1.49 jonathan m_tag_delete_nonpersistent(m);
269 1.32 thorpej
270 1.75 kefren #ifdef MPLS
271 1.75 kefren if (rt != NULL && rt_gettag(rt) != NULL &&
272 1.75 kefren rt_gettag(rt)->sa_family == AF_MPLS &&
273 1.75 kefren (m->m_flags & (M_MCAST | M_BCAST)) == 0) {
274 1.75 kefren union mpls_shim msh;
275 1.75 kefren msh.s_addr = MPLS_GETSADDR(rt);
276 1.75 kefren if (msh.shim.label != MPLS_LABEL_IMPLNULL) {
277 1.75 kefren ifq = &mplsintrq;
278 1.75 kefren isr = NETISR_MPLS;
279 1.75 kefren }
280 1.75 kefren }
281 1.75 kefren if (isr != NETISR_MPLS)
282 1.75 kefren #endif
283 1.1 cgd switch (dst->sa_family) {
284 1.1 cgd
285 1.1 cgd #ifdef INET
286 1.1 cgd case AF_INET:
287 1.73 yamt csum_flags = m->m_pkthdr.csum_flags;
288 1.73 yamt KASSERT((csum_flags & ~(M_CSUM_IPv4|M_CSUM_UDPv4)) == 0);
289 1.73 yamt if (csum_flags != 0 && IN_LOOPBACK_NEED_CHECKSUM(csum_flags)) {
290 1.73 yamt ip_undefer_csum(m, 0, csum_flags);
291 1.73 yamt }
292 1.73 yamt m->m_pkthdr.csum_flags = 0;
293 1.79 rmind pktq = ip_pktq;
294 1.1 cgd break;
295 1.1 cgd #endif
296 1.26 itojun #ifdef INET6
297 1.26 itojun case AF_INET6:
298 1.73 yamt csum_flags = m->m_pkthdr.csum_flags;
299 1.73 yamt KASSERT((csum_flags & ~M_CSUM_UDPv6) == 0);
300 1.73 yamt if (csum_flags != 0 &&
301 1.73 yamt IN6_LOOPBACK_NEED_CHECKSUM(csum_flags)) {
302 1.73 yamt ip6_undefer_csum(m, 0, csum_flags);
303 1.73 yamt }
304 1.73 yamt m->m_pkthdr.csum_flags = 0;
305 1.26 itojun m->m_flags |= M_LOOP;
306 1.79 rmind pktq = ip6_pktq;
307 1.26 itojun break;
308 1.26 itojun #endif
309 1.22 christos #ifdef IPX
310 1.22 christos case AF_IPX:
311 1.22 christos ifq = &ipxintrq;
312 1.22 christos isr = NETISR_IPX;
313 1.19 christos break;
314 1.19 christos #endif
315 1.19 christos #ifdef NETATALK
316 1.19 christos case AF_APPLETALK:
317 1.19 christos ifq = &atintrq2;
318 1.19 christos isr = NETISR_ATALK;
319 1.1 cgd break;
320 1.1 cgd #endif
321 1.1 cgd default:
322 1.17 christos printf("%s: can't handle af%d\n", ifp->if_xname,
323 1.16 christos dst->sa_family);
324 1.1 cgd m_freem(m);
325 1.1 cgd return (EAFNOSUPPORT);
326 1.1 cgd }
327 1.79 rmind
328 1.38 thorpej s = splnet();
329 1.79 rmind if (__predict_true(pktq)) {
330 1.79 rmind int error = 0;
331 1.79 rmind
332 1.79 rmind if (__predict_true(pktq_enqueue(pktq, m, 0))) {
333 1.79 rmind ifp->if_ipackets++;
334 1.79 rmind ifp->if_ibytes += pktlen;
335 1.79 rmind } else {
336 1.79 rmind m_freem(m);
337 1.79 rmind error = ENOBUFS;
338 1.79 rmind }
339 1.79 rmind splx(s);
340 1.79 rmind return error;
341 1.79 rmind }
342 1.1 cgd if (IF_QFULL(ifq)) {
343 1.1 cgd IF_DROP(ifq);
344 1.1 cgd m_freem(m);
345 1.1 cgd splx(s);
346 1.1 cgd return (ENOBUFS);
347 1.1 cgd }
348 1.1 cgd IF_ENQUEUE(ifq, m);
349 1.1 cgd schednetisr(isr);
350 1.1 cgd ifp->if_ipackets++;
351 1.1 cgd ifp->if_ibytes += m->m_pkthdr.len;
352 1.1 cgd splx(s);
353 1.1 cgd return (0);
354 1.1 cgd }
355 1.32 thorpej
356 1.32 thorpej #ifdef ALTQ
357 1.57 thorpej static void
358 1.32 thorpej lostart(struct ifnet *ifp)
359 1.32 thorpej {
360 1.79 rmind for (;;) {
361 1.79 rmind pktqueue_t *pktq = NULL;
362 1.79 rmind struct ifqueue *ifq;
363 1.79 rmind struct mbuf *m;
364 1.79 rmind size_t pktlen;
365 1.79 rmind uint32_t af;
366 1.79 rmind int s, isr;
367 1.32 thorpej
368 1.32 thorpej IFQ_DEQUEUE(&ifp->if_snd, m);
369 1.32 thorpej if (m == NULL)
370 1.32 thorpej return;
371 1.32 thorpej
372 1.32 thorpej af = *(mtod(m, uint32_t *));
373 1.32 thorpej m_adj(m, sizeof(uint32_t));
374 1.32 thorpej
375 1.32 thorpej switch (af) {
376 1.32 thorpej #ifdef INET
377 1.32 thorpej case AF_INET:
378 1.79 rmind pktq = ip_pktq;
379 1.32 thorpej break;
380 1.32 thorpej #endif
381 1.32 thorpej #ifdef INET6
382 1.32 thorpej case AF_INET6:
383 1.32 thorpej m->m_flags |= M_LOOP;
384 1.79 rmind pktq = ip6_pktq;
385 1.32 thorpej break;
386 1.32 thorpej #endif
387 1.32 thorpej #ifdef IPX
388 1.32 thorpej case AF_IPX:
389 1.32 thorpej ifq = &ipxintrq;
390 1.32 thorpej isr = NETISR_IPX;
391 1.32 thorpej break;
392 1.32 thorpej #endif
393 1.32 thorpej #ifdef NETATALK
394 1.32 thorpej case AF_APPLETALK:
395 1.32 thorpej ifq = &atintrq2;
396 1.32 thorpej isr = NETISR_ATALK;
397 1.32 thorpej break;
398 1.32 thorpej #endif
399 1.32 thorpej default:
400 1.32 thorpej printf("%s: can't handle af%d\n", ifp->if_xname, af);
401 1.32 thorpej m_freem(m);
402 1.32 thorpej return;
403 1.32 thorpej }
404 1.79 rmind pktlen = m->m_pkthdr.len;
405 1.32 thorpej
406 1.38 thorpej s = splnet();
407 1.79 rmind if (__predict_true(pktq)) {
408 1.79 rmind if (__predict_false(pktq_enqueue(pktq, m, 0))) {
409 1.79 rmind m_freem(m);
410 1.79 rmind splx(s);
411 1.79 rmind return;
412 1.79 rmind }
413 1.79 rmind ifp->if_ipackets++;
414 1.79 rmind ifp->if_ibytes += pktlen;
415 1.79 rmind splx(s);
416 1.79 rmind continue;
417 1.79 rmind }
418 1.32 thorpej if (IF_QFULL(ifq)) {
419 1.32 thorpej IF_DROP(ifq);
420 1.32 thorpej splx(s);
421 1.32 thorpej m_freem(m);
422 1.32 thorpej return;
423 1.32 thorpej }
424 1.32 thorpej IF_ENQUEUE(ifq, m);
425 1.32 thorpej schednetisr(isr);
426 1.32 thorpej ifp->if_ipackets++;
427 1.79 rmind ifp->if_ibytes += pktlen;
428 1.32 thorpej splx(s);
429 1.32 thorpej }
430 1.32 thorpej }
431 1.32 thorpej #endif /* ALTQ */
432 1.1 cgd
433 1.1 cgd /* ARGSUSED */
434 1.11 mycroft void
435 1.62 christos lortrequest(int cmd, struct rtentry *rt,
436 1.69 dyoung const struct rt_addrinfo *info)
437 1.1 cgd {
438 1.11 mycroft
439 1.1 cgd if (rt)
440 1.52 peter rt->rt_rmx.rmx_mtu = lo0ifp->if_mtu;
441 1.1 cgd }
442 1.1 cgd
443 1.1 cgd /*
444 1.1 cgd * Process an ioctl request.
445 1.1 cgd */
446 1.1 cgd /* ARGSUSED */
447 1.11 mycroft int
448 1.64 christos loioctl(struct ifnet *ifp, u_long cmd, void *data)
449 1.1 cgd {
450 1.30 augustss struct ifaddr *ifa;
451 1.67 dyoung struct ifreq *ifr = data;
452 1.30 augustss int error = 0;
453 1.1 cgd
454 1.1 cgd switch (cmd) {
455 1.1 cgd
456 1.70 dyoung case SIOCINITIFADDR:
457 1.1 cgd ifp->if_flags |= IFF_UP;
458 1.1 cgd ifa = (struct ifaddr *)data;
459 1.76 joerg if (ifa != NULL)
460 1.1 cgd ifa->ifa_rtrequest = lortrequest;
461 1.1 cgd /*
462 1.1 cgd * Everything else is done at a higher level.
463 1.1 cgd */
464 1.48 jonathan break;
465 1.48 jonathan
466 1.48 jonathan case SIOCSIFMTU:
467 1.48 jonathan if ((unsigned)ifr->ifr_mtu > LOMTU_MAX)
468 1.48 jonathan error = EINVAL;
469 1.67 dyoung else if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET){
470 1.67 dyoung error = 0;
471 1.48 jonathan }
472 1.1 cgd break;
473 1.1 cgd
474 1.8 hpeyerl case SIOCADDMULTI:
475 1.8 hpeyerl case SIOCDELMULTI:
476 1.54 peter if (ifr == NULL) {
477 1.8 hpeyerl error = EAFNOSUPPORT; /* XXX */
478 1.8 hpeyerl break;
479 1.8 hpeyerl }
480 1.65 dyoung switch (ifreq_getaddr(cmd, ifr)->sa_family) {
481 1.8 hpeyerl
482 1.8 hpeyerl #ifdef INET
483 1.8 hpeyerl case AF_INET:
484 1.26 itojun break;
485 1.26 itojun #endif
486 1.26 itojun #ifdef INET6
487 1.26 itojun case AF_INET6:
488 1.8 hpeyerl break;
489 1.8 hpeyerl #endif
490 1.11 mycroft
491 1.8 hpeyerl default:
492 1.8 hpeyerl error = EAFNOSUPPORT;
493 1.8 hpeyerl break;
494 1.8 hpeyerl }
495 1.8 hpeyerl break;
496 1.11 mycroft
497 1.1 cgd default:
498 1.70 dyoung error = ifioctl_common(ifp, cmd, data);
499 1.1 cgd }
500 1.1 cgd return (error);
501 1.1 cgd }
502