Source-Changes-HG archive

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

[src/trunk]: src/sys To fix bad pointer dereference on start up when gif is u...



details:   https://anonhg.NetBSD.org/src/rev/02e1228d1fc3
branches:  trunk
changeset: 573270:02e1228d1fc3
user:      enami <enami%NetBSD.org@localhost>
date:      Mon Jan 24 04:46:49 2005 +0000

description:
To fix bad pointer dereference on start up when gif is used,
- Allow rn_init() to be called multiple times, but do nothing except the
  first call.
- Include opt_inet.h so that #ifdef INET works.
- Call rn_init() from encap_init() explicitly rather than depending on the
  order of initialization.

diffstat:

 sys/net/radix.c        |  21 +++++++++++++++------
 sys/netinet/ip_encap.c |   5 +++--
 2 files changed, 18 insertions(+), 8 deletions(-)

diffs (70 lines):

diff -r a41e5f669158 -r 02e1228d1fc3 sys/net/radix.c
--- a/sys/net/radix.c   Mon Jan 24 03:02:45 2005 +0000
+++ b/sys/net/radix.c   Mon Jan 24 04:46:49 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: radix.c,v 1.26 2005/01/23 18:41:56 matt Exp $  */
+/*     $NetBSD: radix.c,v 1.27 2005/01/24 04:46:49 enami Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1993
@@ -36,11 +36,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.26 2005/01/23 18:41:56 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.27 2005/01/24 04:46:49 enami Exp $");
 
 #ifndef _NET_RADIX_H_
 #include <sys/param.h>
 #ifdef _KERNEL
+#include "opt_inet.h"
+
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #define        M_DONTWAIT M_NOWAIT
@@ -943,11 +945,18 @@
 {
        char *cp, *cplim;
 #ifdef _KERNEL
-       struct domain *dom;
+       static int initialized;
+       __link_set_decl(domains, struct domain);
+       struct domain *const *dpp;
 
-       DOMAIN_FOREACH(dom)
-               if (dom->dom_maxrtkey > max_keylen)
-                       max_keylen = dom->dom_maxrtkey;
+       if (initialized)
+               return;
+       initialized = 1;
+
+       __link_set_foreach(dpp, domains) {
+               if ((*dpp)->dom_maxrtkey > max_keylen)
+                       max_keylen = (*dpp)->dom_maxrtkey;
+       }
 #ifdef INET
        encap_setkeylen();
 #endif
diff -r a41e5f669158 -r 02e1228d1fc3 sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c    Mon Jan 24 03:02:45 2005 +0000
+++ b/sys/netinet/ip_encap.c    Mon Jan 24 04:46:49 2005 +0000
@@ -70,7 +70,7 @@
 #define USE_RADIX
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.20 2005/01/24 02:42:49 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.21 2005/01/24 04:46:49 enami Exp $");
 
 #include "opt_mrouting.h"
 #include "opt_inet.h"
@@ -192,8 +192,9 @@
 #ifdef USE_RADIX
        /*
         * initialize radix lookup table.
-        * max_keylen initialization should happen before the call to rn_init().
+        * max_keylen initialization happen in the rn_init().
         */
+       rn_init();
        rn_inithead((void *)&encap_head[0], sizeof(struct sockaddr_pack) << 3);
 #ifdef INET6
        rn_inithead((void *)&encap_head[1], sizeof(struct sockaddr_pack) << 3);



Home | Main Index | Thread Index | Old Index