Make dom_maxrtkey of inet/inet6domain the size of the ip_encap pack
structures. This is far from optimal, but gets rid of iffy #ifdef INET in radix.c. The radix bonsai still needs lots of love before loading domains dynamically is possible...
This commit is contained in:
parent
9d09ecfa96
commit
c6e7028d1c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: radix.c,v 1.39 2008/05/11 20:14:41 dyoung Exp $ */
|
||||
/* $NetBSD: radix.c,v 1.40 2008/11/25 18:28:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1993
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.39 2008/05/11 20:14:41 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.40 2008/11/25 18:28:06 pooka Exp $");
|
||||
|
||||
#ifndef _NET_RADIX_H_
|
||||
#include <sys/param.h>
|
||||
@ -47,7 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.39 2008/05/11 20:14:41 dyoung Exp $");
|
||||
#include <sys/malloc.h>
|
||||
#define M_DONTWAIT M_NOWAIT
|
||||
#include <sys/domain.h>
|
||||
#include <netinet/ip_encap.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@ -1063,9 +1062,6 @@ rn_init()
|
||||
if ((*dpp)->dom_maxrtkey > max_keylen)
|
||||
max_keylen = (*dpp)->dom_maxrtkey;
|
||||
}
|
||||
#ifdef INET
|
||||
encap_setkeylen();
|
||||
#endif
|
||||
#endif
|
||||
if (max_keylen == 0) {
|
||||
log(LOG_ERR,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in_proto.c,v 1.94 2008/04/24 11:38:37 ad Exp $ */
|
||||
/* $NetBSD: in_proto.c,v 1.95 2008/11/25 18:28:05 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.94 2008/04/24 11:38:37 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.95 2008/11/25 18:28:05 pooka Exp $");
|
||||
|
||||
#include "opt_mrouting.h"
|
||||
#include "opt_eon.h" /* ISO CLNL over IP */
|
||||
@ -448,7 +448,8 @@ struct domain inetdomain = {
|
||||
.dom_protosw = inetsw,
|
||||
.dom_protoswNPROTOSW = &inetsw[__arraycount(inetsw)],
|
||||
.dom_rtattach = rn_inithead,
|
||||
.dom_rtoffset = 32, .dom_maxrtkey = sizeof(struct sockaddr_in),
|
||||
.dom_rtoffset = 32,
|
||||
.dom_maxrtkey = sizeof(struct ip_pack4),
|
||||
#ifdef IPSELSRC
|
||||
.dom_ifattach = in_domifattach,
|
||||
.dom_ifdetach = in_domifdetach,
|
||||
|
@ -66,11 +66,15 @@
|
||||
*
|
||||
* FreeBSD is excluded here as they make max_keylen a static variable, and
|
||||
* thus forbid definition of radix table other than proper domains.
|
||||
*
|
||||
* !!!!!!!
|
||||
* !!NOTE: dom_maxrtkey assumes USE_RADIX is defined.
|
||||
* !!!!!!!
|
||||
*/
|
||||
#define USE_RADIX
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.32 2008/04/24 11:38:37 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.33 2008/11/25 18:28:05 pooka Exp $");
|
||||
|
||||
#include "opt_mrouting.h"
|
||||
#include "opt_inet.h"
|
||||
@ -109,24 +113,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.32 2008/04/24 11:38:37 ad Exp $");
|
||||
|
||||
#include <net/net_osdep.h>
|
||||
|
||||
/* to lookup a pair of address using radix tree */
|
||||
struct sockaddr_pack {
|
||||
u_int8_t sp_len;
|
||||
u_int8_t sp_family; /* not really used */
|
||||
/* followed by variable-length data */
|
||||
};
|
||||
|
||||
struct pack4 {
|
||||
struct sockaddr_pack p;
|
||||
struct sockaddr_in mine;
|
||||
struct sockaddr_in yours;
|
||||
};
|
||||
struct pack6 {
|
||||
struct sockaddr_pack p;
|
||||
struct sockaddr_in6 mine;
|
||||
struct sockaddr_in6 yours;
|
||||
};
|
||||
|
||||
enum direction { INBOUND, OUTBOUND };
|
||||
|
||||
#ifdef INET
|
||||
@ -155,19 +141,6 @@ extern int max_keylen; /* radix.c */
|
||||
struct radix_node_head *encap_head[2]; /* 0 for AF_INET, 1 for AF_INET6 */
|
||||
#endif
|
||||
|
||||
void
|
||||
encap_setkeylen(void)
|
||||
{
|
||||
#ifdef USE_RADIX
|
||||
if (sizeof(struct pack4) > max_keylen)
|
||||
max_keylen = sizeof(struct pack4);
|
||||
#ifdef INET6
|
||||
if (sizeof(struct pack6) > max_keylen)
|
||||
max_keylen = sizeof(struct pack6);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
encap_init(void)
|
||||
{
|
||||
@ -205,7 +178,7 @@ static struct encaptab *
|
||||
encap4_lookup(struct mbuf *m, int off, int proto, enum direction dir)
|
||||
{
|
||||
struct ip *ip;
|
||||
struct pack4 pack;
|
||||
struct ip_pack4 pack;
|
||||
struct encaptab *ep, *match;
|
||||
int prio, matchprio;
|
||||
#ifdef USE_RADIX
|
||||
@ -329,7 +302,7 @@ static struct encaptab *
|
||||
encap6_lookup(struct mbuf *m, int off, int proto, enum direction dir)
|
||||
{
|
||||
struct ip6_hdr *ip6;
|
||||
struct pack6 pack;
|
||||
struct ip_pack6 pack;
|
||||
int prio, matchprio;
|
||||
struct encaptab *ep, *match;
|
||||
#ifdef USE_RADIX
|
||||
@ -517,9 +490,9 @@ encap_attach(int af, int proto,
|
||||
int error;
|
||||
int s;
|
||||
size_t l;
|
||||
struct pack4 *pack4;
|
||||
struct ip_pack4 *pack4;
|
||||
#ifdef INET6
|
||||
struct pack6 *pack6;
|
||||
struct ip_pack6 *pack6;
|
||||
#endif
|
||||
|
||||
s = splsoftnet();
|
||||
@ -589,19 +562,19 @@ encap_attach(int af, int proto,
|
||||
ep->maskpack->sa_len = l & 0xff;
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
pack4 = (struct pack4 *)ep->addrpack;
|
||||
pack4 = (struct ip_pack4 *)ep->addrpack;
|
||||
ep->src = (struct sockaddr *)&pack4->mine;
|
||||
ep->dst = (struct sockaddr *)&pack4->yours;
|
||||
pack4 = (struct pack4 *)ep->maskpack;
|
||||
pack4 = (struct ip_pack4 *)ep->maskpack;
|
||||
ep->srcmask = (struct sockaddr *)&pack4->mine;
|
||||
ep->dstmask = (struct sockaddr *)&pack4->yours;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
pack6 = (struct pack6 *)ep->addrpack;
|
||||
pack6 = (struct ip_pack6 *)ep->addrpack;
|
||||
ep->src = (struct sockaddr *)&pack6->mine;
|
||||
ep->dst = (struct sockaddr *)&pack6->yours;
|
||||
pack6 = (struct pack6 *)ep->maskpack;
|
||||
pack6 = (struct ip_pack6 *)ep->maskpack;
|
||||
ep->srcmask = (struct sockaddr *)&pack6->mine;
|
||||
ep->dstmask = (struct sockaddr *)&pack6->yours;
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_encap.h,v 1.12 2008/04/24 11:38:37 ad Exp $ */
|
||||
/* $NetBSD: ip_encap.h,v 1.13 2008/11/25 18:28:05 pooka Exp $ */
|
||||
/* $KAME: ip_encap.h,v 1.7 2000/03/25 07:23:37 sumikawa Exp $ */
|
||||
|
||||
/*
|
||||
@ -55,7 +55,24 @@ struct encaptab {
|
||||
void *arg; /* passed via PACKET_TAG_ENCAP */
|
||||
};
|
||||
|
||||
void encap_setkeylen(void);
|
||||
/* to lookup a pair of address using radix tree */
|
||||
struct sockaddr_pack {
|
||||
u_int8_t sp_len;
|
||||
u_int8_t sp_family; /* not really used */
|
||||
/* followed by variable-length data */
|
||||
};
|
||||
|
||||
struct ip_pack4 {
|
||||
struct sockaddr_pack p;
|
||||
struct sockaddr_in mine;
|
||||
struct sockaddr_in yours;
|
||||
};
|
||||
struct ip_pack6 {
|
||||
struct sockaddr_pack p;
|
||||
struct sockaddr_in6 mine;
|
||||
struct sockaddr_in6 yours;
|
||||
};
|
||||
|
||||
void encap_init(void);
|
||||
void encap4_input(struct mbuf *, ...);
|
||||
int encap6_input(struct mbuf **, int *, int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_proto.c,v 1.82 2008/04/24 11:38:38 ad Exp $ */
|
||||
/* $NetBSD: in6_proto.c,v 1.83 2008/11/25 18:28:06 pooka Exp $ */
|
||||
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.82 2008/04/24 11:38:38 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.83 2008/11/25 18:28:06 pooka Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -408,7 +408,7 @@ struct domain inet6domain = {
|
||||
.dom_protoswNPROTOSW = (const struct protosw *)&inet6sw[sizeof(inet6sw)/sizeof(inet6sw[0])],
|
||||
.dom_rtattach = rn_inithead,
|
||||
.dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr) << 3,
|
||||
.dom_maxrtkey = sizeof(struct sockaddr_in6),
|
||||
.dom_maxrtkey = sizeof(struct ip_pack6),
|
||||
.dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach,
|
||||
.dom_ifqueues = { &ip6intrq, NULL },
|
||||
.dom_link = { NULL },
|
||||
|
Loading…
Reference in New Issue
Block a user