if_ethersubr.c revision 1.17 1 /* $NetBSD: if_ethersubr.c,v 1.17 1995/12/24 03:33:43 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
36 */
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/malloc.h>
42 #include <sys/mbuf.h>
43 #include <sys/protosw.h>
44 #include <sys/socket.h>
45 #include <sys/ioctl.h>
46 #include <sys/errno.h>
47 #include <sys/syslog.h>
48
49 #include <machine/cpu.h>
50
51 #include <net/if.h>
52 #include <net/netisr.h>
53 #include <net/route.h>
54 #include <net/if_llc.h>
55 #include <net/if_dl.h>
56 #include <net/if_types.h>
57
58 #include <netinet/in.h>
59 #ifdef INET
60 #include <netinet/in_var.h>
61 #endif
62 #include <netinet/if_ether.h>
63
64 #ifdef NS
65 #include <netns/ns.h>
66 #include <netns/ns_if.h>
67 #endif
68
69 #ifdef ISO
70 #include <netiso/argo_debug.h>
71 #include <netiso/iso.h>
72 #include <netiso/iso_var.h>
73 #include <netiso/iso_snpac.h>
74 #endif
75
76 #ifdef LLC
77 #include <netccitt/dll.h>
78 #include <netccitt/llc_var.h>
79 #endif
80
81 #if defined(LLC) && defined(CCITT)
82 extern struct ifqueue pkintrq;
83 #endif
84
85 u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
86 #define senderr(e) { error = (e); goto bad;}
87
88 /*
89 * Ethernet output routine.
90 * Encapsulate a packet of type family for the local net.
91 * Assumes that ifp is actually pointer to arpcom structure.
92 */
93 int
94 ether_output(ifp, m0, dst, rt0)
95 register struct ifnet *ifp;
96 struct mbuf *m0;
97 struct sockaddr *dst;
98 struct rtentry *rt0;
99 {
100 u_int16_t etype;
101 int s, error = 0;
102 u_char edst[6];
103 register struct mbuf *m = m0;
104 register struct rtentry *rt;
105 struct mbuf *mcopy = (struct mbuf *)0;
106 register struct ether_header *eh;
107 struct arpcom *ac = (struct arpcom *)ifp;
108
109 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
110 senderr(ENETDOWN);
111 ifp->if_lastchange = time;
112 if (rt = rt0) {
113 if ((rt->rt_flags & RTF_UP) == 0) {
114 if (rt0 = rt = rtalloc1(dst, 1))
115 rt->rt_refcnt--;
116 else
117 senderr(EHOSTUNREACH);
118 }
119 if (rt->rt_flags & RTF_GATEWAY) {
120 if (rt->rt_gwroute == 0)
121 goto lookup;
122 if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
123 rtfree(rt); rt = rt0;
124 lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1);
125 if ((rt = rt->rt_gwroute) == 0)
126 senderr(EHOSTUNREACH);
127 }
128 }
129 if (rt->rt_flags & RTF_REJECT)
130 if (rt->rt_rmx.rmx_expire == 0 ||
131 time.tv_sec < rt->rt_rmx.rmx_expire)
132 senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
133 }
134 switch (dst->sa_family) {
135
136 #ifdef INET
137 case AF_INET:
138 if (!arpresolve(ac, rt, m, dst, edst))
139 return (0); /* if not yet resolved */
140 /* If broadcasting on a simplex interface, loopback a copy */
141 if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
142 mcopy = m_copy(m, 0, (int)M_COPYALL);
143 etype = htons(ETHERTYPE_IP);
144 break;
145 #endif
146 #ifdef NS
147 case AF_NS:
148 etype = htons(ETHERTYPE_NS);
149 bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
150 (caddr_t)edst, sizeof (edst));
151 if (!bcmp((caddr_t)edst, (caddr_t)&ns_thishost, sizeof(edst)))
152 return (looutput(ifp, m, dst, rt));
153 /* If broadcasting on a simplex interface, loopback a copy */
154 if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
155 mcopy = m_copy(m, 0, (int)M_COPYALL);
156 break;
157 #endif
158 #ifdef ISO
159 case AF_ISO: {
160 int snpalen;
161 struct llc *l;
162 register struct sockaddr_dl *sdl;
163
164 if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway) &&
165 sdl->sdl_family == AF_LINK && sdl->sdl_alen > 0) {
166 bcopy(LLADDR(sdl), (caddr_t)edst, sizeof(edst));
167 } else if (error =
168 iso_snparesolve(ifp, (struct sockaddr_iso *)dst,
169 (char *)edst, &snpalen))
170 goto bad; /* Not Resolved */
171 /* If broadcasting on a simplex interface, loopback a copy */
172 if (*edst & 1)
173 m->m_flags |= (M_BCAST|M_MCAST);
174 if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX) &&
175 (mcopy = m_copy(m, 0, (int)M_COPYALL))) {
176 M_PREPEND(mcopy, sizeof (*eh), M_DONTWAIT);
177 if (mcopy) {
178 eh = mtod(mcopy, struct ether_header *);
179 bcopy((caddr_t)edst,
180 (caddr_t)eh->ether_dhost, sizeof (edst));
181 bcopy((caddr_t)ac->ac_enaddr,
182 (caddr_t)eh->ether_shost, sizeof (edst));
183 }
184 }
185 M_PREPEND(m, 3, M_DONTWAIT);
186 if (m == NULL)
187 return (0);
188 etype = htons(m->m_pkthdr.len);
189 l = mtod(m, struct llc *);
190 l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
191 l->llc_control = LLC_UI;
192 IFDEBUG(D_ETHER)
193 int i;
194 printf("unoutput: sending pkt to: ");
195 for (i=0; i<6; i++)
196 printf("%x ", edst[i] & 0xff);
197 printf("\n");
198 ENDDEBUG
199 } break;
200 #endif /* ISO */
201 #ifdef LLC
202 /* case AF_NSAP: */
203 case AF_CCITT: {
204 register struct sockaddr_dl *sdl =
205 (struct sockaddr_dl *) rt -> rt_gateway;
206
207 if (sdl && sdl->sdl_family == AF_LINK
208 && sdl->sdl_alen > 0) {
209 bcopy(LLADDR(sdl), (char *)edst,
210 sizeof(edst));
211 } else goto bad; /* Not a link interface ? Funny ... */
212 if ((ifp->if_flags & IFF_SIMPLEX) && (*edst & 1) &&
213 (mcopy = m_copy(m, 0, (int)M_COPYALL))) {
214 M_PREPEND(mcopy, sizeof (*eh), M_DONTWAIT);
215 if (mcopy) {
216 eh = mtod(mcopy, struct ether_header *);
217 bcopy((caddr_t)edst,
218 (caddr_t)eh->ether_dhost, sizeof (edst));
219 bcopy((caddr_t)ac->ac_enaddr,
220 (caddr_t)eh->ether_shost, sizeof (edst));
221 }
222 }
223 etype = htons(m->m_pkthdr.len);
224 #ifdef LLC_DEBUG
225 {
226 int i;
227 register struct llc *l = mtod(m, struct llc *);
228
229 printf("ether_output: sending LLC2 pkt to: ");
230 for (i=0; i<6; i++)
231 printf("%x ", edst[i] & 0xff);
232 printf(" len 0x%x dsap 0x%x ssap 0x%x control 0x%x\n",
233 m->m_pkthdr.len, l->llc_dsap & 0xff, l->llc_ssap &0xff,
234 l->llc_control & 0xff);
235
236 }
237 #endif /* LLC_DEBUG */
238 } break;
239 #endif /* LLC */
240
241 case AF_UNSPEC:
242 eh = (struct ether_header *)dst->sa_data;
243 bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
244 /* AF_UNSPEC doesn't swap the byte order of the ether_type. */
245 etype = eh->ether_type;
246 break;
247
248 default:
249 printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit,
250 dst->sa_family);
251 senderr(EAFNOSUPPORT);
252 }
253
254 if (mcopy)
255 (void) looutput(ifp, mcopy, dst, rt);
256
257 /*
258 * Add local net header. If no space in first mbuf,
259 * allocate another.
260 */
261 M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT);
262 if (m == 0)
263 senderr(ENOBUFS);
264 eh = mtod(m, struct ether_header *);
265 bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type,
266 sizeof(eh->ether_type));
267 bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
268 bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
269 sizeof(eh->ether_shost));
270 s = splimp();
271 /*
272 * Queue message on interface, and start output if interface
273 * not yet active.
274 */
275 if (IF_QFULL(&ifp->if_snd)) {
276 IF_DROP(&ifp->if_snd);
277 splx(s);
278 senderr(ENOBUFS);
279 }
280 ifp->if_obytes += m->m_pkthdr.len;
281 IF_ENQUEUE(&ifp->if_snd, m);
282 if ((ifp->if_flags & IFF_OACTIVE) == 0)
283 (*ifp->if_start)(ifp);
284 splx(s);
285 if (m->m_flags & M_MCAST)
286 ifp->if_omcasts++;
287 return (error);
288
289 bad:
290 if (m)
291 m_freem(m);
292 return (error);
293 }
294
295 /*
296 * Process a received Ethernet packet;
297 * the packet is in the mbuf chain m without
298 * the ether header, which is provided separately.
299 */
300 void
301 ether_input(ifp, eh, m)
302 struct ifnet *ifp;
303 register struct ether_header *eh;
304 struct mbuf *m;
305 {
306 register struct ifqueue *inq;
307 register struct llc *l;
308 u_int16_t etype;
309 struct arpcom *ac = (struct arpcom *)ifp;
310 int s;
311
312 if ((ifp->if_flags & IFF_UP) == 0) {
313 m_freem(m);
314 return;
315 }
316 ifp->if_lastchange = time;
317 ifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh);
318 if (eh->ether_dhost[0] & 1) {
319 if (bcmp((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
320 sizeof(etherbroadcastaddr)) == 0)
321 m->m_flags |= M_BCAST;
322 else
323 m->m_flags |= M_MCAST;
324 }
325 if (m->m_flags & (M_BCAST|M_MCAST))
326 ifp->if_imcasts++;
327
328 etype = ntohs(eh->ether_type);
329 switch (etype) {
330 #ifdef INET
331 case ETHERTYPE_IP:
332 schednetisr(NETISR_IP);
333 inq = &ipintrq;
334 break;
335
336 case ETHERTYPE_ARP:
337 schednetisr(NETISR_ARP);
338 inq = &arpintrq;
339 break;
340
341 case ETHERTYPE_REVARP:
342 revarpinput(m); /* XXX queue? */
343 return;
344 #endif
345 #ifdef NS
346 case ETHERTYPE_NS:
347 schednetisr(NETISR_NS);
348 inq = &nsintrq;
349 break;
350
351 #endif
352 default:
353 #if defined (ISO) || defined (LLC)
354 if (etype > ETHERMTU)
355 goto dropanyway;
356 l = mtod(m, struct llc *);
357 switch (l->llc_dsap) {
358 #ifdef ISO
359 case LLC_ISO_LSAP:
360 switch (l->llc_control) {
361 case LLC_UI:
362 /* LLC_UI_P forbidden in class 1 service */
363 if ((l->llc_dsap == LLC_ISO_LSAP) &&
364 (l->llc_ssap == LLC_ISO_LSAP)) {
365 /* LSAP for ISO */
366 if (m->m_pkthdr.len > etype)
367 m_adj(m, etype - m->m_pkthdr.len);
368 m->m_data += 3; /* XXX */
369 m->m_len -= 3; /* XXX */
370 m->m_pkthdr.len -= 3; /* XXX */
371 M_PREPEND(m, sizeof *eh, M_DONTWAIT);
372 if (m == 0)
373 return;
374 *mtod(m, struct ether_header *) = *eh;
375 IFDEBUG(D_ETHER)
376 printf("clnp packet");
377 ENDDEBUG
378 schednetisr(NETISR_ISO);
379 inq = &clnlintrq;
380 break;
381 }
382 goto dropanyway;
383
384 case LLC_XID:
385 case LLC_XID_P:
386 if(m->m_len < 6)
387 goto dropanyway;
388 l->llc_window = 0;
389 l->llc_fid = 9;
390 l->llc_class = 1;
391 l->llc_dsap = l->llc_ssap = 0;
392 /* Fall through to */
393 case LLC_TEST:
394 case LLC_TEST_P:
395 {
396 struct sockaddr sa;
397 register struct ether_header *eh2;
398 int i;
399 u_char c = l->llc_dsap;
400
401 l->llc_dsap = l->llc_ssap;
402 l->llc_ssap = c;
403 if (m->m_flags & (M_BCAST | M_MCAST))
404 bcopy((caddr_t)ac->ac_enaddr,
405 (caddr_t)eh->ether_dhost, 6);
406 sa.sa_family = AF_UNSPEC;
407 sa.sa_len = sizeof(sa);
408 eh2 = (struct ether_header *)sa.sa_data;
409 for (i = 0; i < 6; i++) {
410 eh2->ether_shost[i] = c = eh->ether_dhost[i];
411 eh2->ether_dhost[i] =
412 eh->ether_dhost[i] = eh->ether_shost[i];
413 eh->ether_shost[i] = c;
414 }
415 ifp->if_output(ifp, m, &sa, NULL);
416 return;
417 }
418 default:
419 m_freem(m);
420 return;
421 }
422 break;
423 #endif /* ISO */
424 #ifdef LLC
425 case LLC_X25_LSAP:
426 {
427 if (m->m_pkthdr.len > etype)
428 m_adj(m, etype - m->m_pkthdr.len);
429 M_PREPEND(m, sizeof(struct sdl_hdr) , M_DONTWAIT);
430 if (m == 0)
431 return;
432 if ( !sdl_sethdrif(ifp, eh->ether_shost, LLC_X25_LSAP,
433 eh->ether_dhost, LLC_X25_LSAP, 6,
434 mtod(m, struct sdl_hdr *)))
435 panic("ETHER cons addr failure");
436 mtod(m, struct sdl_hdr *)->sdlhdr_len = etype;
437 #ifdef LLC_DEBUG
438 printf("llc packet\n");
439 #endif /* LLC_DEBUG */
440 schednetisr(NETISR_CCITT);
441 inq = &llcintrq;
442 break;
443 }
444 #endif /* LLC */
445 dropanyway:
446 default:
447 m_freem(m);
448 return;
449 }
450 #else /* ISO || LLC */
451 m_freem(m);
452 return;
453 #endif /* ISO || LLC */
454 }
455
456 s = splimp();
457 if (IF_QFULL(inq)) {
458 IF_DROP(inq);
459 m_freem(m);
460 } else
461 IF_ENQUEUE(inq, m);
462 splx(s);
463 }
464
465 /*
466 * Convert Ethernet address to printable (loggable) representation.
467 */
468 static char digits[] = "0123456789abcdef";
469 char *
470 ether_sprintf(ap)
471 register u_char *ap;
472 {
473 register i;
474 static char etherbuf[18];
475 register char *cp = etherbuf;
476
477 for (i = 0; i < 6; i++) {
478 *cp++ = digits[*ap >> 4];
479 *cp++ = digits[*ap++ & 0xf];
480 *cp++ = ':';
481 }
482 *--cp = 0;
483 return (etherbuf);
484 }
485
486 /*
487 * Perform common duties while attaching to interface list
488 */
489 void
490 ether_ifattach(ifp)
491 register struct ifnet *ifp;
492 {
493 register struct ifaddr *ifa;
494 register struct sockaddr_dl *sdl;
495
496 ifp->if_type = IFT_ETHER;
497 ifp->if_addrlen = 6;
498 ifp->if_hdrlen = 14;
499 ifp->if_mtu = ETHERMTU;
500 ifp->if_output = ether_output;
501 for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
502 ifa = ifa->ifa_list.tqe_next)
503 if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
504 sdl->sdl_family == AF_LINK) {
505 sdl->sdl_type = IFT_ETHER;
506 sdl->sdl_alen = ifp->if_addrlen;
507 bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr,
508 LLADDR(sdl), ifp->if_addrlen);
509 break;
510 }
511 LIST_INIT(&((struct arpcom *)ifp)->ac_multiaddrs);
512 }
513
514 u_char ether_ipmulticast_min[6] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
515 u_char ether_ipmulticast_max[6] = { 0x01, 0x00, 0x5e, 0x7f, 0xff, 0xff };
516 /*
517 * Add an Ethernet multicast address or range of addresses to the list for a
518 * given interface.
519 */
520 int
521 ether_addmulti(ifr, ac)
522 struct ifreq *ifr;
523 register struct arpcom *ac;
524 {
525 register struct ether_multi *enm;
526 struct sockaddr_in *sin;
527 u_char addrlo[6];
528 u_char addrhi[6];
529 int s = splimp();
530
531 switch (ifr->ifr_addr.sa_family) {
532
533 case AF_UNSPEC:
534 bcopy(ifr->ifr_addr.sa_data, addrlo, 6);
535 bcopy(addrlo, addrhi, 6);
536 break;
537
538 #ifdef INET
539 case AF_INET:
540 sin = (struct sockaddr_in *)&(ifr->ifr_addr);
541 if (sin->sin_addr.s_addr == INADDR_ANY) {
542 /*
543 * An IP address of INADDR_ANY means listen to all
544 * of the Ethernet multicast addresses used for IP.
545 * (This is for the sake of IP multicast routers.)
546 */
547 bcopy(ether_ipmulticast_min, addrlo, 6);
548 bcopy(ether_ipmulticast_max, addrhi, 6);
549 }
550 else {
551 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo);
552 bcopy(addrlo, addrhi, 6);
553 }
554 break;
555 #endif
556
557 default:
558 splx(s);
559 return (EAFNOSUPPORT);
560 }
561
562 /*
563 * Verify that we have valid Ethernet multicast addresses.
564 */
565 if ((addrlo[0] & 0x01) != 1 || (addrhi[0] & 0x01) != 1) {
566 splx(s);
567 return (EINVAL);
568 }
569 /*
570 * See if the address range is already in the list.
571 */
572 ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm);
573 if (enm != NULL) {
574 /*
575 * Found it; just increment the reference count.
576 */
577 ++enm->enm_refcount;
578 splx(s);
579 return (0);
580 }
581 /*
582 * New address or range; malloc a new multicast record
583 * and link it into the interface's multicast list.
584 */
585 enm = (struct ether_multi *)malloc(sizeof(*enm), M_IFMADDR, M_NOWAIT);
586 if (enm == NULL) {
587 splx(s);
588 return (ENOBUFS);
589 }
590 bcopy(addrlo, enm->enm_addrlo, 6);
591 bcopy(addrhi, enm->enm_addrhi, 6);
592 enm->enm_ac = ac;
593 enm->enm_refcount = 1;
594 LIST_INSERT_HEAD(&ac->ac_multiaddrs, enm, enm_list);
595 ac->ac_multicnt++;
596 splx(s);
597 /*
598 * Return ENETRESET to inform the driver that the list has changed
599 * and its reception filter should be adjusted accordingly.
600 */
601 return (ENETRESET);
602 }
603
604 /*
605 * Delete a multicast address record.
606 */
607 int
608 ether_delmulti(ifr, ac)
609 struct ifreq *ifr;
610 register struct arpcom *ac;
611 {
612 register struct ether_multi *enm;
613 register struct ether_multi **p;
614 struct sockaddr_in *sin;
615 u_char addrlo[6];
616 u_char addrhi[6];
617 int s = splimp();
618
619 switch (ifr->ifr_addr.sa_family) {
620
621 case AF_UNSPEC:
622 bcopy(ifr->ifr_addr.sa_data, addrlo, 6);
623 bcopy(addrlo, addrhi, 6);
624 break;
625
626 #ifdef INET
627 case AF_INET:
628 sin = (struct sockaddr_in *)&(ifr->ifr_addr);
629 if (sin->sin_addr.s_addr == INADDR_ANY) {
630 /*
631 * An IP address of INADDR_ANY means stop listening
632 * to the range of Ethernet multicast addresses used
633 * for IP.
634 */
635 bcopy(ether_ipmulticast_min, addrlo, 6);
636 bcopy(ether_ipmulticast_max, addrhi, 6);
637 }
638 else {
639 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo);
640 bcopy(addrlo, addrhi, 6);
641 }
642 break;
643 #endif
644
645 default:
646 splx(s);
647 return (EAFNOSUPPORT);
648 }
649
650 /*
651 * Look up the address in our list.
652 */
653 ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm);
654 if (enm == NULL) {
655 splx(s);
656 return (ENXIO);
657 }
658 if (--enm->enm_refcount != 0) {
659 /*
660 * Still some claims to this record.
661 */
662 splx(s);
663 return (0);
664 }
665 /*
666 * No remaining claims to this record; unlink and free it.
667 */
668 LIST_REMOVE(enm, enm_list);
669 free(enm, M_IFMADDR);
670 ac->ac_multicnt--;
671 splx(s);
672 /*
673 * Return ENETRESET to inform the driver that the list has changed
674 * and its reception filter should be adjusted accordingly.
675 */
676 return (ENETRESET);
677 }
678