Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet - You can't just call the pfil hook to remove an...



details:   https://anonhg.NetBSD.org/src/rev/d6d2c982db9f
branches:  trunk
changeset: 820196:d6d2c982db9f
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 02 23:00:25 2017 +0000

description:
- 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()

diffstat:

 sys/netinet/in.c     |  10 ++++++----
 sys/netinet/in_var.h |   4 +---
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r 71a029b67d4d -r d6d2c982db9f sys/netinet/in.c
--- 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);
diff -r 71a029b67d4d -r d6d2c982db9f sys/netinet/in_var.h
--- 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. */



Home | Main Index | Thread Index | Old Index