xref: /freebsd/sys/netinet/in.c (revision 17ee9d00bc1ae1e598c38f25826f861e4bc6c3ce)
1 /*
2  * Copyright (c) 1982, 1986, 1991, 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  *	@(#)in.c	8.2 (Berkeley) 11/15/93
34  * $Id: in.c,v 1.8 1994/12/22 21:56:22 wollman Exp $
35  */
36 
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/ioctl.h>
40 #include <sys/errno.h>
41 #include <sys/malloc.h>
42 #include <sys/socket.h>
43 #include <sys/socketvar.h>
44 
45 #include <net/if.h>
46 #include <net/route.h>
47 
48 #include <netinet/in_systm.h>
49 #include <netinet/in.h>
50 #include <netinet/in_var.h>
51 #include <netinet/if_ether.h>
52 
53 #include <netinet/igmp_var.h>
54 
55 /*
56  * Return the network number from an internet address.
57  */
58 u_long
59 in_netof(in)
60 	struct in_addr in;
61 {
62 	register u_long i = ntohl(in.s_addr);
63 	register u_long net;
64 	register struct in_ifaddr *ia;
65 
66 	if (IN_CLASSA(i))
67 		net = i & IN_CLASSA_NET;
68 	else if (IN_CLASSB(i))
69 		net = i & IN_CLASSB_NET;
70 	else if (IN_CLASSC(i))
71 		net = i & IN_CLASSC_NET;
72 	else if (IN_CLASSD(i))
73 		net = i & IN_CLASSD_NET;
74 	else
75 		return (0);
76 
77 	/*
78 	 * Check whether network is a subnet;
79 	 * if so, return subnet number.
80 	 */
81 	for (ia = in_ifaddr; ia; ia = ia->ia_next)
82 		if (net == ia->ia_net)
83 			return (i & ia->ia_subnetmask);
84 	return (net);
85 }
86 
87 #ifndef SUBNETSARELOCAL
88 #define	SUBNETSARELOCAL	1
89 #endif
90 int subnetsarelocal = SUBNETSARELOCAL;
91 /*
92  * Return 1 if an internet address is for a ``local'' host
93  * (one to which we have a connection).  If subnetsarelocal
94  * is true, this includes other subnets of the local net.
95  * Otherwise, it includes only the directly-connected (sub)nets.
96  */
97 int
98 in_localaddr(in)
99 	struct in_addr in;
100 {
101 	register u_long i = ntohl(in.s_addr);
102 	register struct in_ifaddr *ia;
103 
104 	if (subnetsarelocal) {
105 		for (ia = in_ifaddr; ia; ia = ia->ia_next)
106 			if ((i & ia->ia_netmask) == ia->ia_net)
107 				return (1);
108 	} else {
109 		for (ia = in_ifaddr; ia; ia = ia->ia_next)
110 			if ((i & ia->ia_subnetmask) == ia->ia_subnet)
111 				return (1);
112 	}
113 	return (0);
114 }
115 
116 /*
117  * Determine whether an IP address is in a reserved set of addresses
118  * that may not be forwarded, or whether datagrams to that destination
119  * may be forwarded.
120  */
121 int
122 in_canforward(in)
123 	struct in_addr in;
124 {
125 	register u_long i = ntohl(in.s_addr);
126 	register u_long net;
127 
128 	if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i))
129 		return (0);
130 	if (IN_CLASSA(i)) {
131 		net = i & IN_CLASSA_NET;
132 		if (net == 0 || net == (IN_LOOPBACKNET << IN_CLASSA_NSHIFT))
133 			return (0);
134 	}
135 	return (1);
136 }
137 
138 /*
139  * Trim a mask in a sockaddr
140  */
141 void
142 in_socktrim(ap)
143 struct sockaddr_in *ap;
144 {
145     register char *cplim = (char *) &ap->sin_addr;
146     register char *cp = (char *) (&ap->sin_addr + 1);
147 
148     ap->sin_len = 0;
149     while (--cp >= cplim)
150         if (*cp) {
151 	    (ap)->sin_len = cp - (char *) (ap) + 1;
152 	    break;
153 	}
154 }
155 
156 int	in_interfaces;		/* number of external internet interfaces */
157 extern	struct ifnet loif;
158 
159 /*
160  * Generic internet control operations (ioctl's).
161  * Ifp is 0 if not an interface-specific ioctl.
162  */
163 /* ARGSUSED */
164 int
165 in_control(so, cmd, data, ifp)
166 	struct socket *so;
167 	int cmd;
168 	caddr_t data;
169 	register struct ifnet *ifp;
170 {
171 	register struct ifreq *ifr = (struct ifreq *)data;
172 	register struct in_ifaddr *ia = 0;
173 	register struct ifaddr *ifa;
174 	struct in_ifaddr *oia;
175 	struct in_aliasreq *ifra = (struct in_aliasreq *)data;
176 	struct sockaddr_in oldaddr;
177 	int error, hostIsNew, maskIsNew;
178 	u_long i;
179 
180 	/*
181 	 * Find address for this interface, if it exists.
182 	 */
183 	if (ifp)
184 		for (ia = in_ifaddr; ia; ia = ia->ia_next)
185 			if (ia->ia_ifp == ifp)
186 				break;
187 
188 	switch (cmd) {
189 
190 	case SIOCAIFADDR:
191 	case SIOCDIFADDR:
192 		if (ifra->ifra_addr.sin_family == AF_INET)
193 		    for (oia = ia; ia; ia = ia->ia_next) {
194 			if (ia->ia_ifp == ifp  &&
195 			    ia->ia_addr.sin_addr.s_addr ==
196 				ifra->ifra_addr.sin_addr.s_addr)
197 			    break;
198 		}
199 		if (cmd == SIOCDIFADDR && ia == 0)
200 			return (EADDRNOTAVAIL);
201 		/* FALLTHROUGH */
202 	case SIOCSIFADDR:
203 	case SIOCSIFNETMASK:
204 	case SIOCSIFDSTADDR:
205 		if ((so->so_state & SS_PRIV) == 0)
206 			return (EPERM);
207 
208 		if (ifp == 0)
209 			panic("in_control");
210 		if (ia == (struct in_ifaddr *)0) {
211 			oia = (struct in_ifaddr *)
212 				malloc(sizeof *oia, M_IFADDR, M_WAITOK);
213 			if (oia == (struct in_ifaddr *)NULL)
214 				return (ENOBUFS);
215 			bzero((caddr_t)oia, sizeof *oia);
216 			ia = in_ifaddr;
217 			if (ia) {
218 				for ( ; ia->ia_next; ia = ia->ia_next)
219 					continue;
220 				ia->ia_next = oia;
221 			} else
222 				in_ifaddr = oia;
223 			ia = oia;
224 			ifa = ifp->if_addrlist;
225 			if (ifa) {
226 				for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
227 					continue;
228 				ifa->ifa_next = (struct ifaddr *) ia;
229 			} else
230 				ifp->if_addrlist = (struct ifaddr *) ia;
231 			ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
232 			ia->ia_ifa.ifa_dstaddr
233 					= (struct sockaddr *)&ia->ia_dstaddr;
234 			ia->ia_ifa.ifa_netmask
235 					= (struct sockaddr *)&ia->ia_sockmask;
236 			ia->ia_sockmask.sin_len = 8;
237 			if (ifp->if_flags & IFF_BROADCAST) {
238 				ia->ia_broadaddr.sin_len = sizeof(ia->ia_addr);
239 				ia->ia_broadaddr.sin_family = AF_INET;
240 			}
241 			ia->ia_ifp = ifp;
242 			if (ifp != &loif)
243 				in_interfaces++;
244 		}
245 		break;
246 
247 	case SIOCSIFBRDADDR:
248 		if ((so->so_state & SS_PRIV) == 0)
249 			return (EPERM);
250 		/* FALLTHROUGH */
251 
252 	case SIOCGIFADDR:
253 	case SIOCGIFNETMASK:
254 	case SIOCGIFDSTADDR:
255 	case SIOCGIFBRDADDR:
256 		if (ia == (struct in_ifaddr *)0)
257 			return (EADDRNOTAVAIL);
258 		break;
259 	}
260 	switch (cmd) {
261 
262 	case SIOCGIFADDR:
263 		*((struct sockaddr_in *)&ifr->ifr_addr) = ia->ia_addr;
264 		break;
265 
266 	case SIOCGIFBRDADDR:
267 		if ((ifp->if_flags & IFF_BROADCAST) == 0)
268 			return (EINVAL);
269 		*((struct sockaddr_in *)&ifr->ifr_dstaddr) = ia->ia_broadaddr;
270 		break;
271 
272 	case SIOCGIFDSTADDR:
273 		if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
274 			return (EINVAL);
275 		*((struct sockaddr_in *)&ifr->ifr_dstaddr) = ia->ia_dstaddr;
276 		break;
277 
278 	case SIOCGIFNETMASK:
279 		*((struct sockaddr_in *)&ifr->ifr_addr) = ia->ia_sockmask;
280 		break;
281 
282 	case SIOCSIFDSTADDR:
283 		if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
284 			return (EINVAL);
285 		oldaddr = ia->ia_dstaddr;
286 		ia->ia_dstaddr = *(struct sockaddr_in *)&ifr->ifr_dstaddr;
287 		if (ifp->if_ioctl && (error = (*ifp->if_ioctl)
288 					(ifp, SIOCSIFDSTADDR, (caddr_t)ia))) {
289 			ia->ia_dstaddr = oldaddr;
290 			return (error);
291 		}
292 		if (ia->ia_flags & IFA_ROUTE) {
293 			ia->ia_ifa.ifa_dstaddr = (struct sockaddr *)&oldaddr;
294 			rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST);
295 			ia->ia_ifa.ifa_dstaddr =
296 					(struct sockaddr *)&ia->ia_dstaddr;
297 			rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP);
298 		}
299 		break;
300 
301 	case SIOCSIFBRDADDR:
302 		if ((ifp->if_flags & IFF_BROADCAST) == 0)
303 			return (EINVAL);
304 		ia->ia_broadaddr = *(struct sockaddr_in *)&ifr->ifr_broadaddr;
305 		break;
306 
307 	case SIOCSIFADDR:
308 		return (in_ifinit(ifp, ia,
309 		    (struct sockaddr_in *) &ifr->ifr_addr, 1));
310 
311 	case SIOCSIFNETMASK:
312 		i = ifra->ifra_addr.sin_addr.s_addr;
313 		ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr = i);
314 		break;
315 
316 	case SIOCAIFADDR:
317 		maskIsNew = 0;
318 		hostIsNew = 1;
319 		error = 0;
320 		if (ia->ia_addr.sin_family == AF_INET) {
321 			if (ifra->ifra_addr.sin_len == 0) {
322 				ifra->ifra_addr = ia->ia_addr;
323 				hostIsNew = 0;
324 			} else if (ifra->ifra_addr.sin_addr.s_addr ==
325 					       ia->ia_addr.sin_addr.s_addr)
326 				hostIsNew = 0;
327 		}
328 		if (ifra->ifra_mask.sin_len) {
329 			in_ifscrub(ifp, ia);
330 			ia->ia_sockmask = ifra->ifra_mask;
331 			ia->ia_subnetmask =
332 			     ntohl(ia->ia_sockmask.sin_addr.s_addr);
333 			maskIsNew = 1;
334 		}
335 		if ((ifp->if_flags & IFF_POINTOPOINT) &&
336 		    (ifra->ifra_dstaddr.sin_family == AF_INET)) {
337 			in_ifscrub(ifp, ia);
338 			ia->ia_dstaddr = ifra->ifra_dstaddr;
339 			maskIsNew  = 1; /* We lie; but the effect's the same */
340 		}
341 		if (ifra->ifra_addr.sin_family == AF_INET &&
342 		    (hostIsNew || maskIsNew))
343 			error = in_ifinit(ifp, ia, &ifra->ifra_addr, 0);
344 		if ((ifp->if_flags & IFF_BROADCAST) &&
345 		    (ifra->ifra_broadaddr.sin_family == AF_INET))
346 			ia->ia_broadaddr = ifra->ifra_broadaddr;
347 		return (error);
348 
349 	case SIOCDIFADDR:
350 		in_ifscrub(ifp, ia);
351 		if ((ifa = ifp->if_addrlist) == (struct ifaddr *)ia)
352 			ifp->if_addrlist = ifa->ifa_next;
353 		else {
354 			while (ifa->ifa_next &&
355 			       (ifa->ifa_next != (struct ifaddr *)ia))
356 				    ifa = ifa->ifa_next;
357 			if (ifa->ifa_next)
358 				ifa->ifa_next = ((struct ifaddr *)ia)->ifa_next;
359 			else
360 				printf("Couldn't unlink inifaddr from ifp\n");
361 		}
362 		oia = ia;
363 		if (oia == (ia = in_ifaddr))
364 			in_ifaddr = ia->ia_next;
365 		else {
366 			while (ia->ia_next && (ia->ia_next != oia))
367 				ia = ia->ia_next;
368 			if (ia->ia_next)
369 				ia->ia_next = oia->ia_next;
370 			else
371 				printf("Didn't unlink inifadr from list\n");
372 		}
373 		IFAFREE((&oia->ia_ifa));
374 		break;
375 
376 	default:
377 		if (ifp == 0 || ifp->if_ioctl == 0)
378 			return (EOPNOTSUPP);
379 		return ((*ifp->if_ioctl)(ifp, cmd, data));
380 	}
381 	return (0);
382 }
383 
384 /*
385  * Delete any existing route for an interface.
386  */
387 void
388 in_ifscrub(ifp, ia)
389 	register struct ifnet *ifp;
390 	register struct in_ifaddr *ia;
391 {
392 
393 	if ((ia->ia_flags & IFA_ROUTE) == 0)
394 		return;
395 	if (ifp->if_flags & (IFF_LOOPBACK|IFF_POINTOPOINT))
396 		rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST);
397 	else
398 		rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0);
399 	ia->ia_flags &= ~IFA_ROUTE;
400 }
401 
402 /*
403  * Initialize an interface's internet address
404  * and routing table entry.
405  */
406 int
407 in_ifinit(ifp, ia, sin, scrub)
408 	register struct ifnet *ifp;
409 	register struct in_ifaddr *ia;
410 	struct sockaddr_in *sin;
411 	int scrub;
412 {
413 	register u_long i = ntohl(sin->sin_addr.s_addr);
414 	struct sockaddr_in oldaddr;
415 	int s = splimp(), flags = RTF_UP, error;
416 
417 	oldaddr = ia->ia_addr;
418 	ia->ia_addr = *sin;
419 	/*
420 	 * Give the interface a chance to initialize
421 	 * if this is its first address,
422 	 * and to validate the address if necessary.
423 	 */
424 	if (ifp->if_ioctl &&
425 	    (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) {
426 		splx(s);
427 		ia->ia_addr = oldaddr;
428 		return (error);
429 	}
430 	splx(s);
431 	if (scrub) {
432 		ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr;
433 		in_ifscrub(ifp, ia);
434 		ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
435 	}
436 	if (IN_CLASSA(i))
437 		ia->ia_netmask = IN_CLASSA_NET;
438 	else if (IN_CLASSB(i))
439 		ia->ia_netmask = IN_CLASSB_NET;
440 	else
441 		ia->ia_netmask = IN_CLASSC_NET;
442 	/*
443 	 * The subnet mask usually includes at least the standard network part,
444 	 * but may may be smaller in the case of supernetting.
445 	 * If it is set, we believe it.
446 	 */
447 	if (ia->ia_subnetmask == 0) {
448 		ia->ia_subnetmask = ia->ia_netmask;
449 		ia->ia_sockmask.sin_addr.s_addr = htonl(ia->ia_subnetmask);
450 	} else
451 		ia->ia_netmask &= ia->ia_subnetmask;
452 	ia->ia_net = i & ia->ia_netmask;
453 	ia->ia_subnet = i & ia->ia_subnetmask;
454 	in_socktrim(&ia->ia_sockmask);
455 	/*
456 	 * Add route for the network.
457 	 */
458 	ia->ia_ifa.ifa_metric = ifp->if_metric;
459 	if (ifp->if_flags & IFF_BROADCAST) {
460 		ia->ia_broadaddr.sin_addr.s_addr =
461 			htonl(ia->ia_subnet | ~ia->ia_subnetmask);
462 		ia->ia_netbroadcast.s_addr =
463 			htonl(ia->ia_net | ~ ia->ia_netmask);
464 	} else if (ifp->if_flags & IFF_LOOPBACK) {
465 		ia->ia_ifa.ifa_dstaddr = ia->ia_ifa.ifa_addr;
466 		flags |= RTF_HOST;
467 	} else if (ifp->if_flags & IFF_POINTOPOINT) {
468 		if (ia->ia_dstaddr.sin_family != AF_INET)
469 			return (0);
470 		flags |= RTF_HOST;
471 	}
472 	if ((error = rtinit(&(ia->ia_ifa), (int)RTM_ADD, flags)) == 0)
473 		ia->ia_flags |= IFA_ROUTE;
474 	/*
475 	 * If the interface supports multicast, join the "all hosts"
476 	 * multicast group on that interface.
477 	 */
478 	if (ifp->if_flags & IFF_MULTICAST) {
479 		struct in_addr addr;
480 
481 		addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP);
482 		in_addmulti(&addr, ifp);
483 	}
484 	return (error);
485 }
486 
487 
488 /*
489  * Return 1 if the address might be a local broadcast address.
490  */
491 int
492 in_broadcast(in, ifp)
493 	struct in_addr in;
494         struct ifnet *ifp;
495 {
496 	register struct ifaddr *ifa;
497 	u_long t;
498 
499 	if (in.s_addr == INADDR_BROADCAST ||
500 	    in.s_addr == INADDR_ANY)
501 		return 1;
502 	if ((ifp->if_flags & IFF_BROADCAST) == 0)
503 		return 0;
504 	t = ntohl(in.s_addr);
505 	/*
506 	 * Look through the list of addresses for a match
507 	 * with a broadcast address.
508 	 */
509 #define ia ((struct in_ifaddr *)ifa)
510 	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
511 		if (ifa->ifa_addr->sa_family == AF_INET &&
512 		    (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
513 		     in.s_addr == ia->ia_netbroadcast.s_addr ||
514 		     /*
515 		      * Check for old-style (host 0) broadcast.
516 		      */
517 		     t == ia->ia_subnet || t == ia->ia_net))
518 			    return 1;
519 	return (0);
520 #undef ia
521 }
522 /*
523  * Add an address to the list of IP multicast addresses for a given interface.
524  */
525 struct in_multi *
526 in_addmulti(ap, ifp)
527 	register struct in_addr *ap;
528 	register struct ifnet *ifp;
529 {
530 	register struct in_multi *inm;
531 	struct ifreq ifr;
532 	struct in_ifaddr *ia;
533 	int s = splnet();
534 
535 	/*
536 	 * See if address already in list.
537 	 */
538 	IN_LOOKUP_MULTI(*ap, ifp, inm);
539 	if (inm != NULL) {
540 		/*
541 		 * Found it; just increment the reference count.
542 		 */
543 		++inm->inm_refcount;
544 	}
545 	else {
546 		/*
547 		 * New address; allocate a new multicast record
548 		 * and link it into the interface's multicast list.
549 		 */
550 		inm = (struct in_multi *)malloc(sizeof(*inm),
551 		    M_IPMADDR, M_NOWAIT);
552 		if (inm == NULL) {
553 			splx(s);
554 			return (NULL);
555 		}
556 		inm->inm_addr = *ap;
557 		inm->inm_ifp = ifp;
558 		inm->inm_refcount = 1;
559 		IFP_TO_IA(ifp, ia);
560 		if (ia == NULL) {
561 			free(inm, M_IPMADDR);
562 			splx(s);
563 			return (NULL);
564 		}
565 		inm->inm_ia = ia;
566 		inm->inm_next = ia->ia_multiaddrs;
567 		ia->ia_multiaddrs = inm;
568 		/*
569 		 * Ask the network driver to update its multicast reception
570 		 * filter appropriately for the new address.
571 		 */
572 		((struct sockaddr_in *)&ifr.ifr_addr)->sin_family = AF_INET;
573 		((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr = *ap;
574 		if ((ifp->if_ioctl == NULL) ||
575 		    (*ifp->if_ioctl)(ifp, SIOCADDMULTI,(caddr_t)&ifr) != 0) {
576 			ia->ia_multiaddrs = inm->inm_next;
577 			free(inm, M_IPMADDR);
578 			splx(s);
579 			return (NULL);
580 		}
581 		/*
582 		 * Let IGMP know that we have joined a new IP multicast group.
583 		 */
584 		igmp_joingroup(inm);
585 	}
586 	splx(s);
587 	return (inm);
588 }
589 
590 /*
591  * Delete a multicast address record.
592  */
593 void
594 in_delmulti(inm)
595 	register struct in_multi *inm;
596 {
597 	register struct in_multi **p;
598 	struct ifreq ifr;
599 	int s = splnet();
600 
601 	if (--inm->inm_refcount == 0) {
602 		/*
603 		 * No remaining claims to this record; let IGMP know that
604 		 * we are leaving the multicast group.
605 		 */
606 		igmp_leavegroup(inm);
607 		/*
608 		 * Unlink from list.
609 		 */
610 		for (p = &inm->inm_ia->ia_multiaddrs;
611 		     *p != inm;
612 		     p = &(*p)->inm_next)
613 			 continue;
614 		*p = (*p)->inm_next;
615 		/*
616 		 * Notify the network driver to update its multicast reception
617 		 * filter.
618 		 */
619 		((struct sockaddr_in *)&(ifr.ifr_addr))->sin_family = AF_INET;
620 		((struct sockaddr_in *)&(ifr.ifr_addr))->sin_addr =
621 								inm->inm_addr;
622 		(*inm->inm_ifp->if_ioctl)(inm->inm_ifp, SIOCDELMULTI,
623 							     (caddr_t)&ifr);
624 		free(inm, M_IPMADDR);
625 	}
626 	splx(s);
627 }
628