Source-Changes-HG archive

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

[src/trunk]: src/sys/netipsec Retire ipsec_osdep.h



details:   https://anonhg.NetBSD.org/src/rev/bed6a8595bd2
branches:  trunk
changeset: 353065:bed6a8595bd2
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Apr 19 03:39:14 2017 +0000

description:
Retire ipsec_osdep.h

We don't need to care other OSes (FreeBSD) anymore.

Some macros are alive in ipsec_private.h.

diffstat:

 sys/netipsec/ipsec.c         |   35 ++--
 sys/netipsec/ipsec.h         |   15 +-
 sys/netipsec/ipsec_input.c   |    6 +-
 sys/netipsec/ipsec_mbuf.c    |    5 +-
 sys/netipsec/ipsec_osdep.h   |  354 -------------------------------------------
 sys/netipsec/ipsec_output.c  |    7 +-
 sys/netipsec/ipsec_private.h |   14 +-
 sys/netipsec/key.c           |    5 +-
 sys/netipsec/keysock.c       |    7 +-
 sys/netipsec/xform_ah.c      |   11 +-
 sys/netipsec/xform_esp.c     |   12 +-
 sys/netipsec/xform_ipcomp.c  |    8 +-
 sys/netipsec/xform_ipip.c    |   14 +-
 sys/netipsec/xform_tcp.c     |    6 +-
 14 files changed, 69 insertions(+), 430 deletions(-)

diffs (truncated from 942 to 300 lines):

diff -r fc9937ea5727 -r bed6a8595bd2 sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c      Wed Apr 19 03:28:19 2017 +0000
+++ b/sys/netipsec/ipsec.c      Wed Apr 19 03:39:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.c,v 1.74 2017/04/19 03:28:19 ozaki-r Exp $       */
+/*     $NetBSD: ipsec.c,v 1.75 2017/04/19 03:39:14 ozaki-r 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.74 2017/04/19 03:28:19 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.75 2017/04/19 03:39:14 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -101,8 +101,6 @@
 
 #include <netipsec/xform.h>
 
-#include <netipsec/ipsec_osdep.h>
-
 #include <net/net_osdep.h>
 
 int ipsec_used = 0;
@@ -155,7 +153,7 @@
 int    crypto_support = 0;
 
 static struct secpolicy *ipsec_getpolicybysock(struct mbuf *, u_int,
-       PCB_T *, int *);
+    struct inpcb_hdr *, int *);
 
 #ifdef __FreeBSD__
 /* net.inet.ipsec */
@@ -463,7 +461,8 @@
  * NOTE: IPv6 mapped address concern is implemented here.
  */
 static struct secpolicy *
-ipsec_getpolicybysock(struct mbuf *m, u_int dir, PCB_T *inp, int *error)
+ipsec_getpolicybysock(struct mbuf *m, u_int dir, struct inpcb_hdr *inp,
+    int *error)
 {
        struct inpcbpolicy *pcbsp = NULL;
        struct secpolicy *currsp = NULL;        /* policy on socket */
@@ -476,10 +475,10 @@
        KASSERTMSG(dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND,
            "invalid direction %u", dir);
 
-       KASSERT(PCB_SOCKET(inp) != NULL);
+       KASSERT(inp->inph_socket != NULL);
 
        /* XXX FIXME inpcb/in6pcb  vs socket*/
-       af = PCB_FAMILY(inp);
+       af = inp->inph_af;
        KASSERTMSG(af == AF_INET || af == AF_INET6,
            "unexpected protocol family %u", af);
 
@@ -495,7 +494,7 @@
 
        switch (af) {
        case AF_INET: {
-               struct inpcb *in4p = PCB_TO_IN4PCB(inp);
+               struct inpcb *in4p = (struct inpcb *)inp;
                /* set spidx in pcb */
                *error = ipsec4_setspidx_inpcb(m, in4p);
                pcbsp = in4p->inp_sp;
@@ -504,7 +503,7 @@
 
 #if defined(INET6)
        case AF_INET6: {
-               struct in6pcb *in6p = PCB_TO_IN6PCB(inp);
+               struct in6pcb *in6p = (struct in6pcb *)inp;
                /* set spidx in pcb */
                *error = ipsec6_setspidx_in6pcb(m, in6p);
                pcbsp = in6p->in6p_sp;
@@ -644,7 +643,7 @@
        if (inp == NULL || inp->inp_socket == NULL) {
                sp = ipsec_getpolicybyaddr(m, dir, flag, error);
        } else
-               sp = ipsec_getpolicybysock(m, dir, IN4PCB_TO_PCB(inp), error);
+               sp = ipsec_getpolicybysock(m, dir, (struct inpcb_hdr *)inp, error);
        if (sp == NULL) {
                KASSERTMSG(*error != 0, "getpolicy failed w/o error");
                IPSEC_STATINC(IPSEC_STAT_OUT_INVAL);
@@ -889,7 +888,7 @@
        if (in6p == NULL || in6p->in6p_socket == NULL) {
                sp = ipsec_getpolicybyaddr(m, dir, flag, error);
        } else
-               sp = ipsec_getpolicybysock(m, dir, IN6PCB_TO_PCB(in6p), error);
+               sp = ipsec_getpolicybysock(m, dir, (struct inpcb_hdr *)in6p, error);
        if (sp == NULL) {
                KASSERTMSG(*error != 0, "getpolicy failed w/o error");
                IPSEC_STATINC(IPSEC_STAT_OUT_INVAL);
@@ -1071,7 +1070,7 @@
        /* NB: ip_input() flips it into host endian XXX need more checking */
        if (m->m_len >= sizeof(struct ip)) {
                struct ip *ip = mtod(m, struct ip *);
-               if (ip->ip_off & IP_OFF_CONVERT(IP_MF | IP_OFFMASK))
+               if (ip->ip_off & htons(IP_MF | IP_OFFMASK))
                        goto done;
                off = ip->ip_hl << 2;
                nxt = ip->ip_p;
@@ -1079,7 +1078,7 @@
                struct ip ih;
 
                m_copydata(m, 0, sizeof (struct ip), &ih);
-               if (ih.ip_off & IP_OFF_CONVERT(IP_MF | IP_OFFMASK))
+               if (ih.ip_off & htons(IP_MF | IP_OFFMASK))
                        goto done;
                off = ih.ip_hl << 2;
                nxt = ih.ip_p;
@@ -1856,7 +1855,7 @@
                sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_INBOUND, IP_FORWARDING, &error);
        else
                sp = ipsec_getpolicybysock(m, IPSEC_DIR_INBOUND,
-                                          IN4PCB_TO_PCB(inp), &error);
+                                          (struct inpcb_hdr *)inp, &error);
 
        if (sp != NULL) {
                result = ipsec_in_reject(sp, m);
@@ -1896,7 +1895,7 @@
                sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_INBOUND, IP_FORWARDING, &error);
        else
                sp = ipsec_getpolicybysock(m, IPSEC_DIR_INBOUND,
-                       IN6PCB_TO_PCB(in6p),
+                       (struct inpcb_hdr *)in6p,
                        &error);
 
        if (sp != NULL) {
@@ -1994,7 +1993,7 @@
                sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error);
        else
                sp = ipsec_getpolicybysock(m, dir,
-                                          IN4PCB_TO_PCB(inp), &error);
+                                          (struct inpcb_hdr *)inp, &error);
 
        if (sp != NULL) {
                size = ipsec_hdrsiz(sp);
@@ -2029,7 +2028,7 @@
                sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error);
        else
                sp = ipsec_getpolicybysock(m, dir,
-                       IN6PCB_TO_PCB(in6p),
+                       (struct inpcb_hdr *)in6p,
                        &error);
 
        if (sp == NULL)
diff -r fc9937ea5727 -r bed6a8595bd2 sys/netipsec/ipsec.h
--- a/sys/netipsec/ipsec.h      Wed Apr 19 03:28:19 2017 +0000
+++ b/sys/netipsec/ipsec.h      Wed Apr 19 03:39:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.h,v 1.40 2017/04/18 05:25:32 ozaki-r Exp $       */
+/*     $NetBSD: ipsec.h,v 1.41 2017/04/19 03:39:14 ozaki-r Exp $       */
 /*     $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $       */
 /*     $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $  */
 
@@ -48,7 +48,6 @@
 #ifdef _KERNEL
 
 #include <netipsec/keydb.h>
-#include <netipsec/ipsec_osdep.h>
 
 /*
  * Security Policy Index
@@ -361,12 +360,12 @@
 
 #ifdef _KERNEL
 /* External declarations of per-file init functions */
-INITFN void ah_attach(void);
-INITFN void esp_attach(void);
-INITFN void ipcomp_attach(void);
-INITFN void ipe4_attach(void);
-INITFN void ipe4_attach(void);
-INITFN void tcpsignature_attach(void);
+void ah_attach(void);
+void esp_attach(void);
+void ipcomp_attach(void);
+void ipe4_attach(void);
+void ipe4_attach(void);
+void tcpsignature_attach(void);
 
 void ipsec_attach(void);
 
diff -r fc9937ea5727 -r bed6a8595bd2 sys/netipsec/ipsec_input.c
--- a/sys/netipsec/ipsec_input.c        Wed Apr 19 03:28:19 2017 +0000
+++ b/sys/netipsec/ipsec_input.c        Wed Apr 19 03:39:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec_input.c,v 1.40 2017/04/18 05:26:42 ozaki-r Exp $ */
+/*     $NetBSD: ipsec_input.c,v 1.41 2017/04/19 03:39:14 ozaki-r Exp $ */
 /*     $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $ */
 /*     $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $        */
 
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.40 2017/04/18 05:26:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.41 2017/04/19 03:39:14 ozaki-r Exp $");
 
 /*
  * IPsec input processing.
@@ -96,8 +96,6 @@
 #include <netipsec/xform.h>
 #include <netinet6/ip6protosw.h>
 
-#include <netipsec/ipsec_osdep.h>
-
 #include <net/net_osdep.h>
 
 #define        IPSEC_ISTAT(p, x, y, z)                                         \
diff -r fc9937ea5727 -r bed6a8595bd2 sys/netipsec/ipsec_mbuf.c
--- a/sys/netipsec/ipsec_mbuf.c Wed Apr 19 03:28:19 2017 +0000
+++ b/sys/netipsec/ipsec_mbuf.c Wed Apr 19 03:39:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec_mbuf.c,v 1.14 2017/04/18 05:26:42 ozaki-r Exp $  */
+/*     $NetBSD: ipsec_mbuf.c,v 1.15 2017/04/19 03:39:14 ozaki-r Exp $  */
 /*-
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_mbuf.c,v 1.14 2017/04/18 05:26:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_mbuf.c,v 1.15 2017/04/19 03:39:14 ozaki-r Exp $");
 
 /*
  * IPsec-specific mbuf routines.
@@ -46,7 +46,6 @@
 #include <netipsec/ipsec_var.h>
 #include <netipsec/ipsec_private.h>
 
-#include <netipsec/ipsec_osdep.h>
 #include <net/net_osdep.h>
 
 /*
diff -r fc9937ea5727 -r bed6a8595bd2 sys/netipsec/ipsec_osdep.h
--- a/sys/netipsec/ipsec_osdep.h        Wed Apr 19 03:28:19 2017 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*     $NetBSD: ipsec_osdep.h,v 1.26 2016/06/22 10:44:32 knakahara Exp $       */
-/*     $FreeBSD: /repoman/r/ncvs/src/sys/netipsec/ipsec_osdep.h,v 1.1 2003/09/29 22:47:45 sam Exp $    */
-
-/*
- * Copyright (c) 2003 Jonathan Stone (jonathan%cs.stanford.edu@localhost)
- *
- * 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.
- */
-
-#ifndef _NETIPSEC_OSDEP_H_
-#define _NETIPSEC_OSDEP_H_
-
-#ifdef _KERNEL
-/*
- *  Hide porting differences across different 4.4BSD-derived platforms.
- *
- * 1.  KASSERT() differences:
- * 2.  Kernel  Random-number API differences.
- * 3.  Is packet data in an mbuf object writeable?
- * 4.  Packet-header semantics.
- * 5.  Fast mbuf-cluster allocation.
- * 6.  Network packet-output macros.
- * 7.  Elased time, in seconds.
- * 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.
- * 12. Byte order of ip_off
- */
-
-/*
- *  1. KASSERT and spl differences
- *
- * FreeBSD takes an expression and  parenthesized printf() argument-list.
- * NetBSD takes one arg: the expression being asserted.
- * FreeBSD's SPLASSERT() takes an SPL level as 1st arg and a
- * parenthesized printf-format argument list as the second argument.
- *
- * This difference is hidden by two 2-argument macros and one 1-arg macro:



Home | Main Index | Thread Index | Old Index