Source-Changes-HG archive

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

[src/trunk]: src/sys/netipsec Remove __FreeBSD__ and __NetBSD__ switches



details:   https://anonhg.NetBSD.org/src/rev/d233b6010c28
branches:  trunk
changeset: 353032:d233b6010c28
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Apr 18 05:25:32 2017 +0000

description:
Remove __FreeBSD__ and __NetBSD__ switches

No functional changes (except for a debug printf).

Note that there remain some __FreeBSD__ for sysctl knobs which counerparts
to NetBSD don't exist. And ipsec_osdep.h isn't touched yet; tidying it up
requires actual code changes.

diffstat:

 sys/netipsec/ipsec.c        |  65 +-------------------------------
 sys/netipsec/ipsec.h        |  12 +-----
 sys/netipsec/ipsec6.h       |  12 +-----
 sys/netipsec/ipsec_input.c  |  90 +--------------------------------------------
 sys/netipsec/ipsec_mbuf.c   |   8 +---
 sys/netipsec/ipsec_output.c |  26 +------------
 sys/netipsec/key.c          |  17 +-------
 sys/netipsec/key_debug.c    |  13 ++----
 sys/netipsec/xform_ah.c     |  25 +-----------
 sys/netipsec/xform_esp.c    |  14 +------
 sys/netipsec/xform_ipcomp.c |  11 +----
 sys/netipsec/xform_ipip.c   |  28 +-------------
 sys/netipsec/xform_tcp.c    |  11 +----
 13 files changed, 27 insertions(+), 305 deletions(-)

diffs (truncated from 884 to 300 lines):

diff -r cb38d5c42267 -r d233b6010c28 sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c      Tue Apr 18 05:21:34 2017 +0000
+++ b/sys/netipsec/ipsec.c      Tue Apr 18 05:25:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.c,v 1.71 2017/04/06 09:20:07 ozaki-r Exp $       */
+/*     $NetBSD: ipsec.c,v 1.72 2017/04/18 05:25:32 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.71 2017/04/06 09:20:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.72 2017/04/18 05:25:32 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -40,9 +40,6 @@
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
-#ifdef __FreeBSD__
-#include "opt_inet6.h"
-#endif
 #include "opt_ipsec.h"
 #endif
 
@@ -140,7 +137,6 @@
 int ip4_ipsec_ecn = 0;         /* ECN ignore(-1)/forbidden(0)/allowed(1) */
 int ip4_esp_randpad = -1;
 
-#ifdef __NetBSD__
 u_int ipsec_spdgen = 1;                /* SPD generation # */
 
 static struct secpolicy *ipsec_checkpcbcache (struct mbuf *,
@@ -148,7 +144,6 @@
 static int ipsec_fillpcbcache (struct inpcbpolicy *, struct mbuf *,
        struct secpolicy *, int);
 static int ipsec_invalpcbcache (struct inpcbpolicy *, int);
-#endif /* __NetBSD__ */
 
 /*
  * Crypto support requirements:
@@ -163,35 +158,11 @@
        PCB_T *, int *);
 
 #ifdef __FreeBSD__
-SYSCTL_DECL(_net_inet_ipsec);
-
 /* net.inet.ipsec */
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEF_POLICY,
-       def_policy, CTLFLAG_RW, &ip4_def_policy.policy, 0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEF_ESP_TRANSLEV, esp_trans_deflev,
-       CTLFLAG_RW, &ip4_esp_trans_deflev,      0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEF_ESP_NETLEV, esp_net_deflev,
-       CTLFLAG_RW, &ip4_esp_net_deflev,        0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEF_AH_TRANSLEV, ah_trans_deflev,
-       CTLFLAG_RW, &ip4_ah_trans_deflev,       0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEF_AH_NETLEV, ah_net_deflev,
-       CTLFLAG_RW, &ip4_ah_net_deflev, 0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_AH_CLEARTOS,
-       ah_cleartos, CTLFLAG_RW,        &ip4_ah_cleartos,       0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_AH_OFFSETMASK,
-       ah_offsetmask, CTLFLAG_RW,      &ip4_ah_offsetmask,     0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DFBIT,
-       dfbit, CTLFLAG_RW,      &ip4_ipsec_dfbit,       0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_ECN,
-       ecn, CTLFLAG_RW,        &ip4_ipsec_ecn, 0, "");
-SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DEBUG,
-       debug, CTLFLAG_RW,      &ipsec_debug,   0, "");
 SYSCTL_INT(_net_inet_ipsec, IPSECCTL_ESP_RANDPAD,
        esp_randpad, CTLFLAG_RW,        &ip4_esp_randpad,       0, "");
 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, "");
 SYSCTL_INT(_net_inet_ipsec, OID_AUTO, test_replay, CTLFLAG_RW, &ipsec_replay, 0,
        "Emulate replay attack");
 SYSCTL_INT(_net_inet_ipsec, OID_AUTO, test_integrity, CTLFLAG_RW,
@@ -209,27 +180,7 @@
 
 
 #ifdef __FreeBSD__
-SYSCTL_DECL(_net_inet6_ipsec6);
-
 /* net.inet6.ipsec6 */
-#ifdef COMPAT_KAME
-SYSCTL_OID(_net_inet6_ipsec6, IPSECCTL_STATS, stats, CTLFLAG_RD,
-       0,0, compat_ipsecstats_sysctl, "S", "");
-#endif /* COMPAT_KAME */
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEF_POLICY,
-       def_policy, CTLFLAG_RW, &ip4_def_policy.policy, 0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEF_ESP_TRANSLEV, esp_trans_deflev,
-       CTLFLAG_RW, &ip6_esp_trans_deflev,      0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEF_ESP_NETLEV, esp_net_deflev,
-       CTLFLAG_RW, &ip6_esp_net_deflev,        0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEF_AH_TRANSLEV, ah_trans_deflev,
-       CTLFLAG_RW, &ip6_ah_trans_deflev,       0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEF_AH_NETLEV, ah_net_deflev,
-       CTLFLAG_RW, &ip6_ah_net_deflev, 0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_ECN,
-       ecn, CTLFLAG_RW,        &ip6_ipsec_ecn, 0, "");
-SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_DEBUG,
-       debug, CTLFLAG_RW,      &ipsec_debug,   0, "");
 SYSCTL_INT(_net_inet6_ipsec6, IPSECCTL_ESP_RANDPAD,
        esp_randpad, CTLFLAG_RW,        &ip6_esp_randpad,       0, "");
 #endif /* __FreeBSD__ */
@@ -254,7 +205,6 @@
 static void vshiftl (unsigned char *, int, int);
 static size_t ipsec_hdrsiz (const struct secpolicy *);
 
-#ifdef __NetBSD__
 /*
  * Try to validate and use cached policy on a PCB.
  */
@@ -429,7 +379,6 @@
        else
                ipsec_spdgen++;
 }
-#endif /* __NetBSD__ */
 
 /*
  * Return a held reference to the default SP.
@@ -534,7 +483,6 @@
        IPSEC_ASSERT(af == AF_INET || af == AF_INET6,
            ("%s: unexpected protocol family %u", __func__, af));
 
-#ifdef __NetBSD__
        IPSEC_ASSERT(inp->inph_sp != NULL, ("null PCB policy cache"));
        /* If we have a cached entry, and if it is still valid, use it. */
        IPSEC_STATINC(IPSEC_STAT_SPDCACHELOOKUP);
@@ -544,7 +492,6 @@
                return currsp;
        }
        IPSEC_STATINC(IPSEC_STAT_SPDCACHEMISS);
-#endif /* __NetBSD__ */
 
        switch (af) {
        case AF_INET: {
@@ -637,9 +584,7 @@
        KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
            printf("DP %s (priv %u policy %u) allocates SP:%p (refcnt %u)\n",
            __func__, pcbsp->priv, currsp->policy, sp, sp->refcnt));
-#ifdef __NetBSD__
        ipsec_fillpcbcache(pcbsp, m, sp, dir);
-#endif /* __NetBSD__ */
        return sp;
 }
 
@@ -1625,9 +1570,7 @@
        if (inp->inp_sp->sp_out != NULL)
                KEY_FREESP(&inp->inp_sp->sp_out);
 
-#ifdef __NetBSD__
        ipsec_invalpcbcache(inp->inp_sp, IPSEC_DIR_ANY);
-#endif
 
        ipsec_delpcbpolicy(inp->inp_sp);
        inp->inp_sp = NULL;
@@ -1713,9 +1656,7 @@
        if (in6p->in6p_sp->sp_out != NULL)
                KEY_FREESP(&in6p->in6p_sp->sp_out);
 
-#ifdef __NetBSD
        ipsec_invalpcbcache(in6p->in6p_sp, IPSEC_DIR_ANY);
-#endif
 
        ipsec_delpcbpolicy(in6p->in6p_sp);
        in6p->in6p_sp = NULL;
@@ -2516,7 +2457,6 @@
                *sport = *dport = 0;
 }
 
-#ifdef __NetBSD__
 /*
  * XXXJRT This should be done as a protosw init call.
  */
@@ -2539,4 +2479,3 @@
        tcpsignature_attach();
 #endif
 }
-#endif /* __NetBSD__ */
diff -r cb38d5c42267 -r d233b6010c28 sys/netipsec/ipsec.h
--- a/sys/netipsec/ipsec.h      Tue Apr 18 05:21:34 2017 +0000
+++ b/sys/netipsec/ipsec.h      Tue Apr 18 05:25:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.h,v 1.39 2017/04/06 09:20:07 ozaki-r Exp $       */
+/*     $NetBSD: ipsec.h,v 1.40 2017/04/18 05:25:32 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 $  */
 
@@ -119,7 +119,6 @@
        struct secpolicy *sp_out;
        int priv;                       /* privileged socket ? */
 
-#ifdef __NetBSD__
        /* cached policy */
        struct {
                struct secpolicy *cachesp;
@@ -132,14 +131,11 @@
        } sp_cache[3];                  /* XXX 3 == IPSEC_DIR_MAX */
        int sp_cacheflags;
 #define        IPSEC_PCBSP_CONNECTED   1
-#endif /* __NetBSD__ */
 };
 
-#ifdef __NetBSD__
 #define        IPSEC_PCB_SKIP_IPSEC(inpp, dir)                                 \
        ((inpp)->sp_cache[(dir)].cachehint == IPSEC_PCBHINT_NO &&       \
         (inpp)->sp_cache[(dir)].cachegen == ipsec_spdgen)
-#endif /* __NetBSD__ */
 
 /* SP acquiring list table. */
 struct secspacq {
@@ -241,13 +237,11 @@
 /* for openbsd compatibility */
 #define        DPRINTF(x)      do { if (ipsec_debug) printf x; } while (0)
 
-#ifdef __NetBSD__
 void ipsec_pcbconn (struct inpcbpolicy *);
 void ipsec_pcbdisconn (struct inpcbpolicy *);
 void ipsec_invalpcbcacheall (void);
 
 extern u_int ipsec_spdgen;
-#endif /* __NetBSD__ */
 
 struct tdb_ident;
 struct secpolicy *ipsec_getpolicy (const struct tdb_ident*, u_int);
@@ -310,12 +304,8 @@
 int ipsec_updatereplay (u_int32_t, const struct secasvar *);
 
 size_t ipsec4_hdrsiz (struct mbuf *, u_int, struct inpcb *);
-#ifdef __FreeBSD__
-size_t ipsec_hdrsiz_tcp (struct tcpcb *);
-#else
 size_t ipsec4_hdrsiz_tcp (struct tcpcb *);
 #define ipsec4_getpolicybyaddr ipsec_getpolicybyaddr
-#endif
 
 union sockaddr_union;
 const char *ipsec_address(const union sockaddr_union* sa);
diff -r cb38d5c42267 -r d233b6010c28 sys/netipsec/ipsec6.h
--- a/sys/netipsec/ipsec6.h     Tue Apr 18 05:21:34 2017 +0000
+++ b/sys/netipsec/ipsec6.h     Tue Apr 18 05:25:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec6.h,v 1.15 2017/03/03 07:13:06 ozaki-r Exp $      */
+/*     $NetBSD: ipsec6.h,v 1.16 2017/04/18 05:25:32 ozaki-r Exp $      */
 /*     $FreeBSD: src/sys/netipsec/ipsec6.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $     */
 /*     $KAME: ipsec.h,v 1.44 2001/03/23 08:08:47 itojun Exp $  */
 
@@ -40,9 +40,7 @@
 
 #include <net/pfkeyv2.h>
 #include <netipsec/keydb.h>
-#ifdef __NetBSD__
 #include <netinet6/in6_pcb.h>
-#endif
 
 #ifdef _KERNEL
 extern int ip6_esp_trans_deflev;
@@ -83,22 +81,14 @@
 struct ip6_hdr;
 const char *ipsec6_logpacketstr (struct ip6_hdr *, u_int32_t);
 
-#ifdef __NetBSD__
 /* NetBSD protosw ctlin entrypoint */
 void * esp6_ctlinput(int, const struct sockaddr *, void *);
 void * ah6_ctlinput(int, const struct sockaddr *, void *);
-#endif /* __NetBSD__ */
 
 struct m_tag;
 int ipsec6_common_input(struct mbuf **, int *, int);
 int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, 
                                                                        int, int, struct m_tag *);
-
-#ifdef __FreeBSD__
-/* FreeBSD protosw ctlin entrypoint */
-void esp6_ctlinput(int, struct sockaddr *, void *);
-#endif /* __FreeBSD__ */
-
 int ipsec6_process_packet (struct mbuf*,struct ipsecrequest *);
 #endif /*_KERNEL*/
 
diff -r cb38d5c42267 -r d233b6010c28 sys/netipsec/ipsec_input.c
--- a/sys/netipsec/ipsec_input.c        Tue Apr 18 05:21:34 2017 +0000
+++ b/sys/netipsec/ipsec_input.c        Tue Apr 18 05:25:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec_input.c,v 1.38 2017/04/06 09:20:07 ozaki-r Exp $ */
+/*     $NetBSD: ipsec_input.c,v 1.39 2017/04/18 05:25:32 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.38 2017/04/06 09:20:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.39 2017/04/18 05:25:32 ozaki-r Exp $");
 



Home | Main Index | Thread Index | Old Index