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