Reversion of "netkey merge", part 2 (replacement of removed files in the

repository by christos was part 1).  netipsec should now be back as it
was on 2003-09-11, with some very minor changes:

1) Some residual platform-dependent code was moved from ipsec.h to
   ipsec_osdep.h; without this, IPSEC_ASSERT() was multiply defined.  ipsec.h
   now includes ipsec_osdep.h

2) itojun's renaming of netipsec/files.ipsec to netipsec/files.netipsec has
   been left in place (it's arguable which name is less confusing but the
   rename is pretty harmless).

3) Some #endif TOKEN has been replaced by #endif /* TOKEN */; #endif TOKEN
   is invalid and GCC 3 won't compile it.

An i386 kernel with "options FAST_IPSEC" and "options OPENCRYPTO" now
gets through "make depend" but fails to build with errors in ip_input.c.
But it's better than it was (thank heaven for small favors).
This commit is contained in:
tls 2003-10-06 22:05:15 +00:00
parent 3e1a342dd1
commit 9355900ec9
13 changed files with 71 additions and 96 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.c,v 1.3 2003/09/12 11:20:58 itojun Exp $ */
/* $NetBSD: ipsec.c,v 1.4 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.3 2003/09/12 11:20:58 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.4 2003/10/06 22:05:15 tls Exp $");
/*
* IPsec controller part.
@ -90,9 +90,9 @@ __KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.3 2003/09/12 11:20:58 itojun Exp $");
#include <netipsec/ipcomp.h> /*XXX*/
#include <netipsec/ipcomp_var.h>
#include <netkey/key.h>
#include <netkey/keydb.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/keydb.h>
#include <netipsec/key_debug.h>
#include <netipsec/xform.h>
@ -156,7 +156,7 @@ SYSCTL_INT(_net_inet_ipsec, OID_AUTO,
crypto_support, CTLFLAG_RW, &crypto_support,0, "");
SYSCTL_STRUCT(_net_inet_ipsec, OID_AUTO,
ipsecstats, CTLFLAG_RD, &newipsecstat, newipsecstat, "");
#endif __FreeBSD__
#endif /* __FreeBSD__ */
#ifdef INET6

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.h,v 1.2 2003/08/15 03:50:20 jonathan Exp $ */
/* $NetBSD: ipsec.h,v 1.3 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/ipsec.h,v 1.2.4.1 2003/01/24 05:11:35 sam Exp $ */
/* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */
@ -44,6 +44,7 @@
#endif
#include <net/pfkeyv2.h>
#include <netipsec/ipsec_osdep.h>
#include <netipsec/keydb.h>
#ifdef _KERNEL
@ -437,17 +438,6 @@ extern char *ipsec_dump_policy __P((caddr_t, char *));
extern const char *ipsec_strerror __P((void));
#endif /* !_KERNEL */
/*
* Porting glue for impedance mismatches between {free,net,open}bsd
*/
#ifdef __FreeBSD__
#define IPSEC_ASSERT(x, y) KASSERT(x, y)
#define INITFN static
#endif
#ifdef __NetBSD__
#define IPSEC_ASSERT(x, y) KASSERT(x)
#define INITFN extern
/* External declarations of per-file init functions */
INITFN void ah_attach(void);
INITFN void esp_attach(void);
@ -455,6 +445,5 @@ INITFN void ipcomp_attach(void);
INITFN void ipe4_attach(void);
INITFN void ipsec_attach(void);
#endif /* __NetBSD __ */
#endif /* _NETIPSEC_IPSEC_H_ */

View File

@ -1,9 +1,9 @@
/* $NetBSD: ipsec_input.c,v 1.5 2003/09/12 11:20:58 itojun Exp $ */
/* $NetBSD: ipsec_input.c,v 1.6 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/ipsec_input.c,v 1.2.4.1 2003/01/24 05:11:35 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.5 2003/09/12 11:20:58 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.6 2003/10/06 22:05:15 tls Exp $");
/*
* IPsec input processing.
@ -53,8 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.5 2003/09/12 11:20:58 itojun Exp $
#include <netipsec/esp_var.h>
#include <netipsec/ipcomp_var.h>
#include <netkey/key.h>
#include <netkey/keydb.h>
#include <netipsec/key.h>
#include <netipsec/keydb.h>
#include <netipsec/xform.h>
#include <netinet6/ip6protosw.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec_netbsd.c,v 1.2 2003/09/12 11:20:58 itojun Exp $ */
/* $NetBSD: ipsec_netbsd.c,v 1.3 2003/10/06 22:05:15 tls Exp $ */
/* $KAME: esp_input.c,v 1.60 2001/09/04 08:43:19 itojun Exp $ */
/* $KAME: ah_input.c,v 1.64 2001/09/04 08:43:19 itojun Exp $ */
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.2 2003/09/12 11:20:58 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.3 2003/10/06 22:05:15 tls Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -70,9 +70,9 @@ __KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.2 2003/09/12 11:20:58 itojun Exp
#ifdef FAST_IPSEC
#include <netipsec/ipsec.h>
#include <netkey/key.h>
#include <netkey/keydb.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/keydb.h>
#include <netipsec/key_debug.h>
#include <netipsec/ah_var.h>
#endif
@ -81,7 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.2 2003/09/12 11:20:58 itojun Exp
#include <netkey/key.h>
#include <netipsec/key.h>
/* assumes that ip header and ah header are contiguous on mbuf */
void *

View File

@ -1,33 +1,8 @@
/* $NetBSD: ipsec_osdep.h,v 1.2 2003/09/29 22:35:43 jonathan Exp $ */
/* $NetBSD: ipsec_osdep.h,v 1.3 2003/10/06 22:05:15 tls Exp $ */
#ifndef NETIPSEC_OSDEP_H
#define NETIPSEC_OSDEP_H
/*
* Copyright (c) 2003 Jonathan Stone (jonathan@cs.stanford.edu)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Hide porting differences across different 4.4BSD-derived platforms.
*
@ -41,6 +16,7 @@
* 8. Test if a socket object opened by a privileged (super) user.
* 9. Global SLIST of all open raw sockets.
* 10. Global SLIST of known interface addresses.
* 11. Type of initialization functions.
*/
/*
@ -127,7 +103,7 @@ read_random(void *bufp, u_int len)
* is empty, new clusters are allocated en-masse).
* On NetBSD, for now, implement the `cache' as an inline function
*using normal NetBSD mbuf/cluster allocation macros. Replace this
* with fast-cache code, if and when netBSD implements one.
* with fast-cache code, if and when NetBSD implements one.
*/
#ifdef __NetBSD__
static __inline struct mbuf *
@ -253,8 +229,15 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
#define ia_link ia_list
#endif /* __NetBSD__ */
/*
* 11. Type of initialization functions.
*/
#ifdef __FreeBSD__
#define INITFN static
#endif
#ifdef __NetBSD__
#define INITFN extern
#endif
/*
* Differences that we don't attempt to hide:
@ -298,5 +281,4 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
* FreeBSD splnet() equates directly to NetBSD's splsoftnet();
* FreeBSD uses splimp() where (for networking) NetBSD would use splnet().
*/
#endif NETIPSEC_OSDEP_H
#endif /* NETIPSEC_OSDEP_H */

View File

@ -1,9 +1,9 @@
/* $NetBSD: ipsec_output.c,v 1.6 2003/09/12 11:20:58 itojun Exp $ */
/* $NetBSD: ipsec_output.c,v 1.7 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/ipsec_output.c,v 1.3.2.1 2003/01/24 05:11:35 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.6 2003/09/12 11:20:58 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.7 2003/10/06 22:05:15 tls Exp $");
/*
* IPsec output processing.
@ -55,9 +55,9 @@ __KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.6 2003/09/12 11:20:58 itojun Exp
#include <netipsec/xform.h>
#include <netkey/key.h>
#include <netkey/keydb.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/keydb.h>
#include <netipsec/key_debug.h>
#include <netipsec/ipsec_osdep.h>
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.2 2003/08/20 22:33:40 jonathan Exp $ */
/* $NetBSD: key.c,v 1.3 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/key.c,v 1.3.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.2 2003/08/20 22:33:40 jonathan Exp $");
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.3 2003/10/06 22:05:15 tls Exp $");
/*
* This code is referd to RFC 2367
@ -256,7 +256,7 @@ SYSCTL_INT(_net_key, KEYCTL_AH_KEYMIN, ah_keymin, CTLFLAG_RW, \
/* perfered old SA rather than new SA */
SYSCTL_INT(_net_key, KEYCTL_PREFERED_OLDSA, prefered_oldsa, CTLFLAG_RW,\
&key_prefered_oldsa, 0, "");
#endif SYSCTL_INT
#endif /* SYSCTL_INT */
#ifndef LIST_FOREACH
#define LIST_FOREACH(elm, head, field) \

View File

@ -1,4 +1,4 @@
/* $NetBSD: key_debug.c,v 1.2 2003/08/20 22:33:40 jonathan Exp $ */
/* $NetBSD: key_debug.c,v 1.3 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/key_debug.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */
@ -33,7 +33,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: key_debug.c,v 1.2 2003/08/20 22:33:40 jonathan Exp $");
__KERNEL_RCSID(0, "$NetBSD: key_debug.c,v 1.3 2003/10/06 22:05:15 tls Exp $");
#endif
#include "opt_inet.h"
@ -651,7 +651,7 @@ kdebug_mbufhdr(m)
"ext_size:%u ext_ref:%p }\n",
m->m_ext.ext_buf, m->m_ext.ext_free,
m->m_ext.ext_size, m->m_ext.ext_ref);
#endif __FreeBSD__
#endif /* __FreeBSD__ */
}
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: keysock.c,v 1.1 2003/08/13 20:06:51 jonathan Exp $ */
/* $NetBSD: keysock.c,v 1.2 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.1 2003/08/13 20:06:51 jonathan Exp $");
__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.2 2003/10/06 22:05:15 tls Exp $");
#include "opt_ipsec.h"
@ -634,7 +634,7 @@ key_usrreq(so, req, m, nam, control, p)
/* sysctl */
#ifdef SYSCTL_NODE
SYSCTL_NODE(_net, PF_KEY, key, CTLFLAG_RW, 0, "Key Family");
#endif SYSCTL_NODE
#endif /* SYSCTL_NODE */
/*
* Definitions of protocols supported in the KEY domain.

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ah.c,v 1.3 2003/09/12 11:21:00 itojun Exp $ */
/* $NetBSD: xform_ah.c,v 1.4 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
/*
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.3 2003/09/12 11:21:00 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.4 2003/10/06 22:05:15 tls Exp $");
#include "opt_inet.h"
#ifdef __FreeBSD__
@ -74,8 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.3 2003/09/12 11:21:00 itojun Exp $");
#include <netinet6/ip6_ecn.h>
#endif
#include <netkey/key.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/key_debug.h>
#include <netipsec/ipsec_osdep.h>
#include <opencrypto/cryptodev.h>
@ -108,7 +108,7 @@ SYSCTL_INT(_net_inet_ah, OID_AUTO,
SYSCTL_STRUCT(_net_inet_ah, IPSECCTL_STATS,
stats, CTLFLAG_RD, &ahstat, ahstat, "");
#endif __FreeBSD__
#endif /* __FreeBSD__ */
static unsigned char ipseczeroes[256]; /* larger than an ip6 extension hdr */

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_esp.c,v 1.3 2003/09/12 11:21:00 itojun Exp $ */
/* $NetBSD: xform_esp.c,v 1.4 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.3 2003/09/12 11:21:00 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.4 2003/10/06 22:05:15 tls Exp $");
#include "opt_inet.h"
#ifdef __FreeBSD__
@ -77,8 +77,8 @@ __KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.3 2003/09/12 11:21:00 itojun Exp $")
#include <netinet6/ip6_ecn.h>
#endif
#include <netkey/key.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/key_debug.h>
#include <netipsec/ipsec_osdep.h>
@ -94,7 +94,7 @@ SYSCTL_INT(_net_inet_esp, OID_AUTO,
esp_enable, CTLFLAG_RW, &esp_enable, 0, "");
SYSCTL_STRUCT(_net_inet_esp, IPSECCTL_STATS,
stats, CTLFLAG_RD, &espstat, espstat, "");
#endif __FreeBSD__
#endif /* __FreeBSD__ */
static int esp_max_ivlen; /* max iv length over all algorithms */

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ipcomp.c,v 1.3 2003/09/12 11:21:00 itojun Exp $ */
/* $NetBSD: xform_ipcomp.c,v 1.4 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.3 2003/09/12 11:21:00 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.4 2003/10/06 22:05:15 tls Exp $");
/* IP payload compression protocol (IPComp), see RFC 2393 */
#include "opt_inet.h"
@ -63,8 +63,8 @@ __KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.3 2003/09/12 11:21:00 itojun Exp
#include <netipsec/ipcomp.h>
#include <netipsec/ipcomp_var.h>
#include <netkey/key.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/key_debug.h>
#include <netipsec/ipsec_osdep.h>
@ -75,13 +75,13 @@ __KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.3 2003/09/12 11:21:00 itojun Exp
int ipcomp_enable = 0;
struct ipcompstat ipcompstat;
#ifdef __freeBSD__
#ifdef __FreeBSD__
SYSCTL_DECL(_net_inet_ipcomp);
SYSCTL_INT(_net_inet_ipcomp, OID_AUTO,
ipcomp_enable, CTLFLAG_RW, &ipcomp_enable, 0, "");
SYSCTL_STRUCT(_net_inet_ipcomp, IPSECCTL_STATS,
stats, CTLFLAG_RD, &ipcompstat, ipcompstat, "");
#endif __FreeBSD__
#endif /* __FreeBSD__ */
static int ipcomp_input_cb(struct cryptop *crp);
static int ipcomp_output_cb(struct cryptop *crp);
@ -613,4 +613,4 @@ ipcomp_attach(void)
#ifdef __FreeBSD__
SYSINIT(ipcomp_xform_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, ipcomp_attach, NULL)
#endif __FreeBSD__
#endif /* __FreeBSD__ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ipip.c,v 1.4 2003/09/12 11:21:00 itojun Exp $ */
/* $NetBSD: xform_ipip.c,v 1.5 2003/10/06 22:05:15 tls Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ipip.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.4 2003/09/12 11:21:00 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.5 2003/10/06 22:05:15 tls Exp $");
/*
* IP-inside-IP processing
@ -91,8 +91,8 @@ __KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.4 2003/09/12 11:21:00 itojun Exp $"
#include <netinet6/ip6protosw.h>
#endif
#include <netkey/key.h>
#include <netkey/key_debug.h>
#include <netipsec/key.h>
#include <netipsec/key_debug.h>
#include <netipsec/ipsec_osdep.h>
#include <machine/stdarg.h>
@ -484,7 +484,11 @@ ipip_output(
ipo->ip_src = saidx->src.sin.sin_addr;
ipo->ip_dst = saidx->dst.sin.sin_addr;
ipo->ip_id = htons(ip_randomid());
#ifdef RANDOM_IP_ID
ipo->ip_id = ip_randomid();
#else
ipo->ip_id = htons(ip_id++);
#endif
/* If the inner protocol is IP... */
if (tp == IPVERSION) {