Sun Oct 18 13:07:31 2020 UTC ()
Suppress the "rn_init: radix functions require max_keylen be set"
message when _KERNEL is defined, to avoid spurious messages from
kernels that have no routable network domains.  Fixes PR kern/55691.


(gson)
diff -r1.48 -r1.49 src/sys/net/radix.c

cvs diff -r1.48 -r1.49 src/sys/net/radix.c (expand / switch to unified diff)

--- src/sys/net/radix.c 2018/09/03 16:29:35 1.48
+++ src/sys/net/radix.c 2020/10/18 13:07:31 1.49
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: radix.c,v 1.48 2018/09/03 16:29:35 riastradh Exp $ */ 1/* $NetBSD: radix.c,v 1.49 2020/10/18 13:07:31 gson Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1993 4 * Copyright (c) 1988, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * @(#)radix.c 8.6 (Berkeley) 10/17/95 31 * @(#)radix.c 8.6 (Berkeley) 10/17/95
32 */ 32 */
33 33
34/* 34/*
35 * Routines to build and maintain radix trees for routing lookups. 35 * Routines to build and maintain radix trees for routing lookups.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.48 2018/09/03 16:29:35 riastradh Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.49 2020/10/18 13:07:31 gson Exp $");
40 40
41#ifndef _NET_RADIX_H_ 41#ifndef _NET_RADIX_H_
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/queue.h> 43#include <sys/queue.h>
44#include <sys/kmem.h> 44#include <sys/kmem.h>
45#ifdef _KERNEL 45#ifdef _KERNEL
46#ifdef _KERNEL_OPT 46#ifdef _KERNEL_OPT
47#include "opt_inet.h" 47#include "opt_inet.h"
48#endif 48#endif
49 49
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/malloc.h> 51#include <sys/malloc.h>
52#define M_DONTWAIT M_NOWAIT 52#define M_DONTWAIT M_NOWAIT
@@ -1109,28 +1109,30 @@ rn_init(void) @@ -1109,28 +1109,30 @@ rn_init(void)
1109#ifdef _KERNEL 1109#ifdef _KERNEL
1110 struct domain *dp; 1110 struct domain *dp;
1111 1111
1112 if (radix_initialized) 1112 if (radix_initialized)
1113 panic("radix already initialized"); 1113 panic("radix already initialized");
1114 radix_initialized = 1; 1114 radix_initialized = 1;
1115 1115
1116 DOMAIN_FOREACH(dp) { 1116 DOMAIN_FOREACH(dp) {
1117 if (dp->dom_maxrtkey > max_keylen) 1117 if (dp->dom_maxrtkey > max_keylen)
1118 max_keylen = dp->dom_maxrtkey; 1118 max_keylen = dp->dom_maxrtkey;
1119 } 1119 }
1120#endif 1120#endif
1121 if (max_keylen == 0) { 1121 if (max_keylen == 0) {
 1122#ifndef _KERNEL
1122 log(LOG_ERR, 1123 log(LOG_ERR,
1123 "rn_init: radix functions require max_keylen be set\n"); 1124 "rn_init: radix functions require max_keylen be set\n");
 1125#endif
1124 return; 1126 return;
1125 } 1127 }
1126 1128
1127 R_Malloc(rn_zeros, char *, 3 * max_keylen); 1129 R_Malloc(rn_zeros, char *, 3 * max_keylen);
1128 if (rn_zeros == NULL) 1130 if (rn_zeros == NULL)
1129 panic("rn_init"); 1131 panic("rn_init");
1130 memset(rn_zeros, 0, 3 * max_keylen); 1132 memset(rn_zeros, 0, 3 * max_keylen);
1131 rn_ones = cp = rn_zeros + max_keylen; 1133 rn_ones = cp = rn_zeros + max_keylen;
1132 addmask_key = cplim = rn_ones + max_keylen; 1134 addmask_key = cplim = rn_ones + max_keylen;
1133 while (cp < cplim) 1135 while (cp < cplim)
1134 *cp++ = -1; 1136 *cp++ = -1;
1135 if (rn_inithead((void *)&mask_rnhead, 0) == 0) 1137 if (rn_inithead((void *)&mask_rnhead, 0) == 0)
1136 panic("rn_init 2"); 1138 panic("rn_init 2");