- You can't just call the pfil hook to remove an address before an address trunk
authorchristos <christos@NetBSD.org>
Mon, 02 Jan 2017 23:00:25 +0000
branchtrunk
changeset 247293 55aa8ad6937d
parent 247292 0763e8644acf
child 247294 32ffaf9dc39a
- You can't just call the pfil hook to remove an address before an address is removed! Hold a reference instead, remove it, and then free it. - GC iatoifa()
sys/netinet/in.c
sys/netinet/in_var.h
--- a/sys/netinet/in.c	Mon Jan 02 21:49:51 2017 +0000
+++ b/sys/netinet/in.c	Mon Jan 02 23:00:25 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.194 2016/12/31 09:41:05 ryo Exp $	*/
+/*	$NetBSD: in.c,v 1.195 2017/01/02 23:00:25 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.194 2016/12/31 09:41:05 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.195 2017/01/02 23:00:25 christos Exp $");
 
 #include "arp.h"
 
@@ -668,9 +668,11 @@
 		break;
 
 	case SIOCDIFADDR:
-		pfil_run_addrhooks(if_pfil, cmd, iatoifa(ia));
 		ia4_release(ia, &psref);
+		ifaref(&ia->ia_ifa);
 		in_purgeaddr(&ia->ia_ifa);
+		pfil_run_addrhooks(if_pfil, cmd, &ia->ia_ifa);
+		ifafree(&ia->ia_ifa);
 		ia = NULL;
 		break;
 
@@ -705,7 +707,7 @@
 
 	if (error == 0) {
 		if (run_hook)
-			pfil_run_addrhooks(if_pfil, cmd, iatoifa(ia));
+			pfil_run_addrhooks(if_pfil, cmd, &ia->ia_ifa);
 	} else if (newifaddr) {
 		KASSERT(ia != NULL);
 		in_purgeaddr(&ia->ia_ifa);
--- a/sys/netinet/in_var.h	Mon Jan 02 21:49:51 2017 +0000
+++ b/sys/netinet/in_var.h	Mon Jan 02 23:00:25 2017 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_var.h,v 1.90 2016/12/06 07:01:47 knakahara Exp $	*/
+/*	$NetBSD: in_var.h,v 1.91 2017/01/02 23:00:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -148,8 +148,6 @@
  */
 #define	IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr))
 
-#define iatoifa(ia)	(struct ifaddr *)(ia)
-
 #ifdef _KERNEL
 
 /* Note: 61, 127, 251, 509, 1021, 2039 are good. */