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: if_ethersubr.c,v 1.6 1995/03/16 18:14:25 bde Exp $ 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 #define senderr(e) { error = (e); goto bad;} 86 87 /* 88 * Ethernet output routine. 89 * Encapsulate a packet of type family for the local net. 90 * Use trailer local net encapsulation if enough data in first 91 * packet leaves a multiple of 512 bytes of data in remainder. 92 * Assumes that ifp is actually pointer to arpcom structure. 93 */ 94 int 95 ether_output(ifp, m0, dst, rt0) 96 register struct ifnet *ifp; 97 struct mbuf *m0; 98 struct sockaddr *dst; 99 struct rtentry *rt0; 100 { 101 short type; 102 int s, error = 0; 103 u_char edst[6]; 104 register struct mbuf *m = m0; 105 register struct rtentry *rt; 106 struct mbuf *mcopy = (struct mbuf *)0; 107 register struct ether_header *eh; 108 int off, len = m->m_pkthdr.len; 109 struct arpcom *ac = (struct arpcom *)ifp; 110 111 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 112 senderr(ENETDOWN); 113 ifp->if_lastchange = time; 114 if (rt = rt0) { 115 if ((rt->rt_flags & RTF_UP) == 0) { 116 if (rt0 = rt = rtalloc1(dst, 1, 0UL)) 117 rt->rt_refcnt--; 118 else 119 senderr(EHOSTUNREACH); 120 } 121 if (rt->rt_flags & RTF_GATEWAY) { 122 if (rt->rt_gwroute == 0) 123 goto lookup; 124 if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) { 125 rtfree(rt); rt = rt0; 126 lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1, 127 0UL); 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, rt0)) 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 (void)memcpy(edst, eh->ether_dhost, 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 (void)memcpy(&eh->ether_type, &type, 271 sizeof(eh->ether_type)); 272 (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); 273 (void)memcpy(eh->ether_shost, ac->ac_enaddr, 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 u_short ether_type; 315 int s; 316 317 if ((ifp->if_flags & IFF_UP) == 0) { 318 m_freem(m); 319 return; 320 } 321 ifp->if_lastchange = time; 322 ifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh); 323 if (bcmp((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost, 324 sizeof(etherbroadcastaddr)) == 0) 325 m->m_flags |= M_BCAST; 326 else if (eh->ether_dhost[0] & 1) 327 m->m_flags |= M_MCAST; 328 if (m->m_flags & (M_BCAST|M_MCAST)) 329 ifp->if_imcasts++; 330 331 ether_type = ntohs(eh->ether_type); 332 333 switch (ether_type) { 334 #ifdef INET 335 case ETHERTYPE_IP: 336 schednetisr(NETISR_IP); 337 inq = &ipintrq; 338 break; 339 340 case ETHERTYPE_ARP: 341 schednetisr(NETISR_ARP); 342 inq = &arpintrq; 343 break; 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 (ether_type > 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 > ether_type) 367 m_adj(m, ether_type - 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 > ether_type) 428 m_adj(m, ether_type - 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 = ether_type; 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 for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) 501 if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && 502 sdl->sdl_family == AF_LINK) { 503 sdl->sdl_type = IFT_ETHER; 504 sdl->sdl_alen = ifp->if_addrlen; 505 bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr, 506 LLADDR(sdl), ifp->if_addrlen); 507 break; 508 } 509 } 510 511 u_char ether_ipmulticast_min[6] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 }; 512 u_char ether_ipmulticast_max[6] = { 0x01, 0x00, 0x5e, 0x7f, 0xff, 0xff }; 513 /* 514 * Add an Ethernet multicast address or range of addresses to the list for a 515 * given interface. 516 */ 517 int 518 ether_addmulti(ifr, ac) 519 struct ifreq *ifr; 520 register struct arpcom *ac; 521 { 522 register struct ether_multi *enm; 523 struct sockaddr_in *sin; 524 u_char addrlo[6]; 525 u_char addrhi[6]; 526 int s = splimp(); 527 528 switch (ifr->ifr_addr.sa_family) { 529 530 case AF_UNSPEC: 531 bcopy(ifr->ifr_addr.sa_data, addrlo, 6); 532 bcopy(addrlo, addrhi, 6); 533 break; 534 535 #ifdef INET 536 case AF_INET: 537 sin = (struct sockaddr_in *)&(ifr->ifr_addr); 538 if (sin->sin_addr.s_addr == INADDR_ANY) { 539 /* 540 * An IP address of INADDR_ANY means listen to all 541 * of the Ethernet multicast addresses used for IP. 542 * (This is for the sake of IP multicast routers.) 543 */ 544 bcopy(ether_ipmulticast_min, addrlo, 6); 545 bcopy(ether_ipmulticast_max, addrhi, 6); 546 } 547 else { 548 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo); 549 bcopy(addrlo, addrhi, 6); 550 } 551 break; 552 #endif 553 554 default: 555 splx(s); 556 return (EAFNOSUPPORT); 557 } 558 559 /* 560 * Verify that we have valid Ethernet multicast addresses. 561 */ 562 if ((addrlo[0] & 0x01) != 1 || (addrhi[0] & 0x01) != 1) { 563 splx(s); 564 return (EINVAL); 565 } 566 /* 567 * See if the address range is already in the list. 568 */ 569 ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm); 570 if (enm != NULL) { 571 /* 572 * Found it; just increment the reference count. 573 */ 574 ++enm->enm_refcount; 575 splx(s); 576 return (0); 577 } 578 /* 579 * New address or range; malloc a new multicast record 580 * and link it into the interface's multicast list. 581 */ 582 enm = (struct ether_multi *)malloc(sizeof(*enm), M_IFMADDR, M_NOWAIT); 583 if (enm == NULL) { 584 splx(s); 585 return (ENOBUFS); 586 } 587 bcopy(addrlo, enm->enm_addrlo, 6); 588 bcopy(addrhi, enm->enm_addrhi, 6); 589 enm->enm_ac = ac; 590 enm->enm_refcount = 1; 591 enm->enm_next = ac->ac_multiaddrs; 592 ac->ac_multiaddrs = enm; 593 ac->ac_multicnt++; 594 splx(s); 595 /* 596 * Return ENETRESET to inform the driver that the list has changed 597 * and its reception filter should be adjusted accordingly. 598 */ 599 return (ENETRESET); 600 } 601 602 /* 603 * Delete a multicast address record. 604 */ 605 int 606 ether_delmulti(ifr, ac) 607 struct ifreq *ifr; 608 register struct arpcom *ac; 609 { 610 register struct ether_multi *enm; 611 register struct ether_multi **p; 612 struct sockaddr_in *sin; 613 u_char addrlo[6]; 614 u_char addrhi[6]; 615 int s = splimp(); 616 617 switch (ifr->ifr_addr.sa_family) { 618 619 case AF_UNSPEC: 620 bcopy(ifr->ifr_addr.sa_data, addrlo, 6); 621 bcopy(addrlo, addrhi, 6); 622 break; 623 624 #ifdef INET 625 case AF_INET: 626 sin = (struct sockaddr_in *)&(ifr->ifr_addr); 627 if (sin->sin_addr.s_addr == INADDR_ANY) { 628 /* 629 * An IP address of INADDR_ANY means stop listening 630 * to the range of Ethernet multicast addresses used 631 * for IP. 632 */ 633 bcopy(ether_ipmulticast_min, addrlo, 6); 634 bcopy(ether_ipmulticast_max, addrhi, 6); 635 } 636 else { 637 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo); 638 bcopy(addrlo, addrhi, 6); 639 } 640 break; 641 #endif 642 643 default: 644 splx(s); 645 return (EAFNOSUPPORT); 646 } 647 648 /* 649 * Look up the address in our list. 650 */ 651 ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm); 652 if (enm == NULL) { 653 splx(s); 654 return (ENXIO); 655 } 656 if (--enm->enm_refcount != 0) { 657 /* 658 * Still some claims to this record. 659 */ 660 splx(s); 661 return (0); 662 } 663 /* 664 * No remaining claims to this record; unlink and free it. 665 */ 666 for (p = &enm->enm_ac->ac_multiaddrs; 667 *p != enm; 668 p = &(*p)->enm_next) 669 continue; 670 *p = (*p)->enm_next; 671 free(enm, M_IFMADDR); 672 ac->ac_multicnt--; 673 splx(s); 674 /* 675 * Return ENETRESET to inform the driver that the list has changed 676 * and its reception filter should be adjusted accordingly. 677 */ 678 return (ENETRESET); 679 } 680