Home | History | Annotate | Line # | Download | only in netipsec
ipsec_netbsd.c revision 1.28.8.1
      1  1.28.8.1      matt /*	$NetBSD: ipsec_netbsd.c,v 1.28.8.1 2007/11/06 23:34:13 matt Exp $	*/
      2       1.1  jonathan /*	$KAME: esp_input.c,v 1.60 2001/09/04 08:43:19 itojun Exp $	*/
      3       1.1  jonathan /*	$KAME: ah_input.c,v 1.64 2001/09/04 08:43:19 itojun Exp $	*/
      4       1.1  jonathan 
      5       1.1  jonathan /*
      6       1.1  jonathan  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      7       1.1  jonathan  * All rights reserved.
      8       1.1  jonathan  *
      9       1.1  jonathan  * Redistribution and use in source and binary forms, with or without
     10       1.1  jonathan  * modification, are permitted provided that the following conditions
     11       1.1  jonathan  * are met:
     12       1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     13       1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     14       1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     16       1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     17       1.1  jonathan  * 3. Neither the name of the project nor the names of its contributors
     18       1.1  jonathan  *    may be used to endorse or promote products derived from this software
     19       1.1  jonathan  *    without specific prior written permission.
     20       1.1  jonathan  *
     21       1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     22       1.1  jonathan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23       1.1  jonathan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24       1.1  jonathan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     25       1.1  jonathan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26       1.1  jonathan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27       1.1  jonathan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28       1.1  jonathan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29       1.1  jonathan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30       1.1  jonathan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31       1.1  jonathan  * SUCH DAMAGE.
     32       1.1  jonathan  */
     33       1.1  jonathan 
     34       1.1  jonathan #include <sys/cdefs.h>
     35  1.28.8.1      matt __KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.28.8.1 2007/11/06 23:34:13 matt Exp $");
     36       1.1  jonathan 
     37       1.1  jonathan #include "opt_inet.h"
     38       1.1  jonathan #include "opt_ipsec.h"
     39       1.1  jonathan 
     40       1.1  jonathan #include <sys/param.h>
     41       1.1  jonathan #include <sys/systm.h>
     42       1.1  jonathan #include <sys/malloc.h>
     43       1.1  jonathan #include <sys/mbuf.h>
     44       1.1  jonathan #include <sys/domain.h>
     45       1.1  jonathan #include <sys/protosw.h>
     46       1.1  jonathan #include <sys/socket.h>
     47       1.1  jonathan #include <sys/errno.h>
     48       1.1  jonathan #include <sys/time.h>
     49       1.1  jonathan #include <sys/kernel.h>
     50       1.1  jonathan #include <sys/sysctl.h>
     51       1.1  jonathan 
     52       1.1  jonathan #include <net/if.h>
     53       1.1  jonathan #include <net/route.h>
     54       1.1  jonathan #include <net/netisr.h>
     55  1.28.8.1      matt #include <sys/cpu.h>
     56       1.1  jonathan 
     57       1.1  jonathan #include <netinet/in.h>
     58       1.1  jonathan #include <netinet/in_systm.h>
     59       1.1  jonathan #include <netinet/in_var.h>
     60       1.1  jonathan #include <netinet/ip.h>
     61       1.1  jonathan #include <netinet/ip_var.h>
     62       1.1  jonathan #include <netinet/ip_ecn.h>
     63       1.1  jonathan #include <netinet/ip_icmp.h>
     64       1.1  jonathan 
     65       1.1  jonathan 
     66       1.1  jonathan #include <netipsec/ipsec.h>
     67      1.10  jonathan #include <netipsec/ipsec_var.h>
     68       1.3       tls #include <netipsec/key.h>
     69       1.3       tls #include <netipsec/keydb.h>
     70       1.3       tls #include <netipsec/key_debug.h>
     71      1.18  degroote #include <netipsec/ah.h>
     72       1.1  jonathan #include <netipsec/ah_var.h>
     73       1.5  jonathan #include <netipsec/esp.h>
     74      1.10  jonathan #include <netipsec/esp_var.h>
     75      1.10  jonathan #include <netipsec/ipip_var.h>
     76      1.10  jonathan #include <netipsec/ipcomp_var.h>
     77       1.5  jonathan 
     78       1.5  jonathan #ifdef INET6
     79       1.5  jonathan #include <netipsec/ipsec6.h>
     80       1.5  jonathan #include <netinet6/ip6protosw.h>
     81       1.5  jonathan #include <netinet/icmp6.h>
     82       1.1  jonathan #endif
     83       1.1  jonathan 
     84       1.1  jonathan #include <machine/stdarg.h>
     85       1.1  jonathan 
     86       1.1  jonathan 
     87       1.1  jonathan 
     88       1.3       tls #include <netipsec/key.h>
     89       1.1  jonathan 
     90       1.1  jonathan /* assumes that ip header and ah header are contiguous on mbuf */
     91      1.20  degroote void*
     92      1.28  degroote ah4_ctlinput(int cmd, const struct sockaddr *sa, void *v)
     93       1.1  jonathan {
     94       1.1  jonathan 	struct ip *ip = v;
     95       1.1  jonathan 	struct ah *ah;
     96       1.1  jonathan 	struct icmp *icp;
     97       1.1  jonathan 	struct secasvar *sav;
     98       1.1  jonathan 
     99       1.1  jonathan 	if (sa->sa_family != AF_INET ||
    100      1.18  degroote 		sa->sa_len != sizeof(struct sockaddr_in))
    101      1.20  degroote 		return NULL;
    102       1.1  jonathan 	if ((unsigned)cmd >= PRC_NCMDS)
    103       1.1  jonathan 		return NULL;
    104      1.20  degroote 
    105       1.1  jonathan 	if (cmd == PRC_MSGSIZE && ip_mtudisc && ip && ip->ip_v == 4) {
    106       1.1  jonathan 		/*
    107       1.1  jonathan 		 * Check to see if we have a valid SA corresponding to
    108       1.1  jonathan 		 * the address in the ICMP message payload.
    109       1.1  jonathan 		 */
    110      1.23  degroote 		ah = (struct ah *)((char *)ip + (ip->ip_hl << 2));
    111      1.20  degroote 		sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
    112      1.27  degroote 					   	IPPROTO_AH, ah->ah_spi, 0, 0);
    113       1.1  jonathan 
    114      1.20  degroote 		if (sav) {
    115      1.20  degroote         	if (sav->state == SADB_SASTATE_MATURE ||
    116      1.20  degroote                 sav->state == SADB_SASTATE_DYING) {
    117      1.20  degroote 
    118      1.20  degroote 				/*
    119      1.20  degroote 				 * Now that we've validated that we are actually
    120      1.20  degroote 				 * communicating with the host indicated in the
    121      1.20  degroote 				 * ICMP message, locate the ICMP header,
    122      1.20  degroote 				 * recalculate the new MTU, and create the
    123      1.20  degroote 		 		 * corresponding routing entry.
    124      1.20  degroote 		 		 */
    125      1.23  degroote 				icp = (struct icmp *)((char *)ip -
    126      1.20  degroote 									  offsetof(struct icmp, icmp_ip));
    127      1.20  degroote 				icmp_mtudisc(icp, ip->ip_dst);
    128       1.1  jonathan 
    129      1.20  degroote 			}
    130      1.21  degroote 			KEY_FREESAV(&sav);
    131      1.20  degroote 		}
    132       1.1  jonathan 	}
    133       1.1  jonathan 	return NULL;
    134       1.1  jonathan }
    135       1.1  jonathan 
    136      1.20  degroote 
    137      1.20  degroote 
    138       1.1  jonathan /* assumes that ip header and esp header are contiguous on mbuf */
    139      1.20  degroote void*
    140      1.28  degroote esp4_ctlinput(int cmd, const struct sockaddr *sa, void *v)
    141       1.1  jonathan {
    142       1.1  jonathan 	struct ip *ip = v;
    143       1.1  jonathan 	struct esp *esp;
    144       1.1  jonathan 	struct icmp *icp;
    145       1.1  jonathan 	struct secasvar *sav;
    146       1.1  jonathan 
    147       1.1  jonathan 	if (sa->sa_family != AF_INET ||
    148       1.1  jonathan 	    sa->sa_len != sizeof(struct sockaddr_in))
    149       1.1  jonathan 		return NULL;
    150       1.1  jonathan 	if ((unsigned)cmd >= PRC_NCMDS)
    151       1.1  jonathan 		return NULL;
    152      1.20  degroote 
    153       1.1  jonathan 	if (cmd == PRC_MSGSIZE && ip_mtudisc && ip && ip->ip_v == 4) {
    154       1.1  jonathan 		/*
    155       1.1  jonathan 		 * Check to see if we have a valid SA corresponding to
    156       1.1  jonathan 		 * the address in the ICMP message payload.
    157       1.1  jonathan 		 */
    158      1.23  degroote 		esp = (struct esp *)((char *)ip + (ip->ip_hl << 2));
    159      1.20  degroote 		sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
    160      1.27  degroote 					   	IPPROTO_ESP, esp->esp_spi, 0, 0);
    161       1.1  jonathan 
    162      1.20  degroote 		if (sav) {
    163      1.20  degroote         	if (sav->state == SADB_SASTATE_MATURE ||
    164      1.20  degroote                 sav->state == SADB_SASTATE_DYING) {
    165      1.20  degroote 
    166      1.20  degroote 				/*
    167      1.20  degroote 				 * Now that we've validated that we are actually
    168      1.20  degroote 				 * communicating with the host indicated in the
    169      1.20  degroote 				 * ICMP message, locate the ICMP header,
    170      1.20  degroote 				 * recalculate the new MTU, and create the
    171      1.20  degroote 		 		 * corresponding routing entry.
    172      1.20  degroote 		 		 */
    173      1.20  degroote 
    174      1.23  degroote 				icp = (struct icmp *)((char *)ip -
    175      1.20  degroote 									   offsetof(struct icmp, icmp_ip));
    176      1.20  degroote 				icmp_mtudisc(icp, ip->ip_dst);
    177       1.1  jonathan 
    178      1.20  degroote 			}
    179      1.21  degroote 			KEY_FREESAV(&sav);
    180      1.20  degroote 		}
    181       1.1  jonathan 	}
    182       1.1  jonathan 	return NULL;
    183       1.1  jonathan }
    184       1.1  jonathan 
    185       1.1  jonathan #ifdef INET6
    186       1.1  jonathan void
    187      1.28  degroote ah6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
    188      1.18  degroote {
    189      1.18  degroote        const struct newah *ahp;
    190      1.18  degroote        struct newah ah;
    191      1.18  degroote        struct secasvar *sav;
    192      1.18  degroote        struct ip6_hdr *ip6;
    193      1.18  degroote        struct mbuf *m;
    194      1.18  degroote        struct ip6ctlparam *ip6cp = NULL;
    195      1.18  degroote        int off;
    196      1.18  degroote 
    197      1.18  degroote        if (sa->sa_family != AF_INET6 ||
    198      1.18  degroote            sa->sa_len != sizeof(struct sockaddr_in6))
    199      1.18  degroote                return;
    200      1.18  degroote        if ((unsigned)cmd >= PRC_NCMDS)
    201      1.18  degroote                return;
    202      1.18  degroote 
    203      1.18  degroote        /* if the parameter is from icmp6, decode it. */
    204      1.18  degroote        if (d != NULL) {
    205      1.18  degroote                ip6cp = (struct ip6ctlparam *)d;
    206      1.18  degroote                m = ip6cp->ip6c_m;
    207      1.18  degroote                ip6 = ip6cp->ip6c_ip6;
    208      1.18  degroote                off = ip6cp->ip6c_off;
    209      1.18  degroote        } else {
    210      1.18  degroote                m = NULL;
    211      1.18  degroote                ip6 = NULL;
    212      1.18  degroote                off = 0;
    213      1.18  degroote        }
    214      1.18  degroote 
    215      1.18  degroote        if (ip6) {
    216      1.18  degroote                /*
    217      1.18  degroote                 * XXX: We assume that when ip6 is non NULL,
    218      1.18  degroote                 * M and OFF are valid.
    219      1.18  degroote                 */
    220      1.18  degroote 
    221      1.18  degroote                /* check if we can safely examine src and dst ports */
    222      1.18  degroote                if (m->m_pkthdr.len < off + sizeof(ah))
    223      1.18  degroote                        return;
    224      1.18  degroote 
    225      1.18  degroote                if (m->m_len < off + sizeof(ah)) {
    226      1.18  degroote                        /*
    227      1.18  degroote                         * this should be rare case,
    228      1.18  degroote                         * so we compromise on this copy...
    229      1.18  degroote                         */
    230      1.24  degroote                        m_copydata(m, off, sizeof(ah), &ah);
    231      1.18  degroote                        ahp = &ah;
    232      1.18  degroote                } else
    233      1.23  degroote                        ahp = (struct newah *)(mtod(m, char *) + off);
    234      1.18  degroote 
    235      1.18  degroote                if (cmd == PRC_MSGSIZE) {
    236      1.18  degroote                        int valid = 0;
    237      1.18  degroote 
    238      1.18  degroote                        /*
    239      1.18  degroote                         * Check to see if we have a valid SA corresponding
    240      1.18  degroote                         * to the address in the ICMP message payload.
    241      1.18  degroote                         */
    242      1.19  degroote                        sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
    243      1.27  degroote                                          IPPROTO_AH, ahp->ah_spi, 0, 0);
    244      1.18  degroote 
    245      1.18  degroote                        if (sav) {
    246      1.18  degroote                                if (sav->state == SADB_SASTATE_MATURE ||
    247      1.18  degroote                                    sav->state == SADB_SASTATE_DYING)
    248      1.18  degroote                                        valid++;
    249      1.18  degroote                                KEY_FREESAV(&sav);
    250      1.18  degroote                        }
    251      1.18  degroote 
    252      1.18  degroote                        /* XXX Further validation? */
    253      1.18  degroote 
    254      1.18  degroote                        /*
    255      1.18  degroote                         * Depending on the value of "valid" and routing
    256      1.18  degroote                         * table size (mtudisc_{hi,lo}wat), we will:
    257      1.18  degroote                         * - recalcurate the new MTU and create the
    258      1.18  degroote                         *   corresponding routing entry, or
    259      1.18  degroote                         * - ignore the MTU change notification.
    260      1.18  degroote                         */
    261      1.18  degroote                        icmp6_mtudisc_update((struct ip6ctlparam *)d,valid);
    262      1.18  degroote                }
    263      1.18  degroote 
    264      1.18  degroote                /* we normally notify single pcb here */
    265      1.18  degroote        } else {
    266      1.18  degroote                /* we normally notify any pcb here */
    267      1.18  degroote        }
    268      1.18  degroote }
    269      1.18  degroote 
    270      1.18  degroote 
    271      1.18  degroote 
    272      1.18  degroote void
    273      1.28  degroote esp6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
    274       1.1  jonathan {
    275       1.1  jonathan 	const struct newesp *espp;
    276       1.1  jonathan 	struct newesp esp;
    277       1.1  jonathan 	struct ip6ctlparam *ip6cp = NULL, ip6cp1;
    278       1.1  jonathan 	struct secasvar *sav;
    279       1.1  jonathan 	struct ip6_hdr *ip6;
    280       1.1  jonathan 	struct mbuf *m;
    281       1.1  jonathan 	int off;
    282       1.1  jonathan 
    283       1.1  jonathan 	if (sa->sa_family != AF_INET6 ||
    284       1.1  jonathan 	    sa->sa_len != sizeof(struct sockaddr_in6))
    285       1.1  jonathan 		return;
    286       1.1  jonathan 	if ((unsigned)cmd >= PRC_NCMDS)
    287       1.1  jonathan 		return;
    288       1.1  jonathan 
    289       1.1  jonathan 	/* if the parameter is from icmp6, decode it. */
    290       1.1  jonathan 	if (d != NULL) {
    291       1.1  jonathan 		ip6cp = (struct ip6ctlparam *)d;
    292       1.1  jonathan 		m = ip6cp->ip6c_m;
    293       1.1  jonathan 		ip6 = ip6cp->ip6c_ip6;
    294       1.1  jonathan 		off = ip6cp->ip6c_off;
    295       1.1  jonathan 	} else {
    296       1.1  jonathan 		m = NULL;
    297       1.1  jonathan 		ip6 = NULL;
    298       1.7  jonathan 		off = 0;
    299       1.1  jonathan 	}
    300       1.1  jonathan 
    301       1.1  jonathan 	if (ip6) {
    302       1.1  jonathan 		/*
    303       1.1  jonathan 		 * Notify the error to all possible sockets via pfctlinput2.
    304       1.1  jonathan 		 * Since the upper layer information (such as protocol type,
    305       1.1  jonathan 		 * source and destination ports) is embedded in the encrypted
    306       1.1  jonathan 		 * data and might have been cut, we can't directly call
    307       1.1  jonathan 		 * an upper layer ctlinput function. However, the pcbnotify
    308       1.1  jonathan 		 * function will consider source and destination addresses
    309       1.1  jonathan 		 * as well as the flow info value, and may be able to find
    310       1.1  jonathan 		 * some PCB that should be notified.
    311       1.1  jonathan 		 * Although pfctlinput2 will call esp6_ctlinput(), there is
    312       1.1  jonathan 		 * no possibility of an infinite loop of function calls,
    313       1.1  jonathan 		 * because we don't pass the inner IPv6 header.
    314       1.1  jonathan 		 */
    315      1.20  degroote 		memset(&ip6cp1, 0, sizeof(ip6cp1));
    316       1.1  jonathan 		ip6cp1.ip6c_src = ip6cp->ip6c_src;
    317      1.24  degroote 		pfctlinput2(cmd, sa, &ip6cp1);
    318       1.1  jonathan 
    319       1.1  jonathan 		/*
    320       1.1  jonathan 		 * Then go to special cases that need ESP header information.
    321       1.1  jonathan 		 * XXX: We assume that when ip6 is non NULL,
    322       1.1  jonathan 		 * M and OFF are valid.
    323       1.1  jonathan 		 */
    324       1.1  jonathan 
    325       1.1  jonathan 		/* check if we can safely examine src and dst ports */
    326       1.1  jonathan 		if (m->m_pkthdr.len < off + sizeof(esp))
    327       1.1  jonathan 			return;
    328       1.1  jonathan 
    329       1.1  jonathan 		if (m->m_len < off + sizeof(esp)) {
    330       1.1  jonathan 			/*
    331       1.1  jonathan 			 * this should be rare case,
    332       1.1  jonathan 			 * so we compromise on this copy...
    333       1.1  jonathan 			 */
    334      1.24  degroote 			m_copydata(m, off, sizeof(esp), &esp);
    335       1.1  jonathan 			espp = &esp;
    336       1.1  jonathan 		} else
    337      1.23  degroote 			espp = (struct newesp*)(mtod(m, char *) + off);
    338       1.1  jonathan 
    339       1.1  jonathan 		if (cmd == PRC_MSGSIZE) {
    340       1.1  jonathan 			int valid = 0;
    341       1.1  jonathan 
    342       1.1  jonathan 			/*
    343       1.1  jonathan 			 * Check to see if we have a valid SA corresponding to
    344       1.1  jonathan 			 * the address in the ICMP message payload.
    345       1.1  jonathan 			 */
    346      1.19  degroote 
    347      1.19  degroote 			sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
    348      1.27  degroote 					  IPPROTO_ESP, espp->esp_spi, 0, 0);
    349       1.7  jonathan 
    350       1.1  jonathan 			if (sav) {
    351       1.1  jonathan 				if (sav->state == SADB_SASTATE_MATURE ||
    352       1.1  jonathan 				    sav->state == SADB_SASTATE_DYING)
    353       1.1  jonathan 					valid++;
    354       1.7  jonathan 				KEY_FREESAV(&sav);
    355       1.1  jonathan 			}
    356       1.1  jonathan 
    357       1.1  jonathan 			/* XXX Further validation? */
    358       1.1  jonathan 
    359       1.1  jonathan 			/*
    360       1.1  jonathan 			 * Depending on the value of "valid" and routing table
    361       1.1  jonathan 			 * size (mtudisc_{hi,lo}wat), we will:
    362       1.1  jonathan 			 * - recalcurate the new MTU and create the
    363       1.1  jonathan 			 *   corresponding routing entry, or
    364       1.1  jonathan 			 * - ignore the MTU change notification.
    365       1.1  jonathan 			 */
    366       1.1  jonathan 			icmp6_mtudisc_update((struct ip6ctlparam *)d, valid);
    367       1.1  jonathan 		}
    368       1.1  jonathan 	} else {
    369       1.1  jonathan 		/* we normally notify any pcb here */
    370       1.1  jonathan 	}
    371       1.1  jonathan }
    372       1.1  jonathan #endif /* INET6 */
    373       1.1  jonathan 
    374       1.4    atatat static int
    375       1.4    atatat sysctl_fast_ipsec(SYSCTLFN_ARGS)
    376       1.1  jonathan {
    377       1.4    atatat 	int error, t;
    378       1.4    atatat 	struct sysctlnode node;
    379       1.4    atatat 
    380       1.4    atatat 	node = *rnode;
    381       1.4    atatat 	t = *(int*)rnode->sysctl_data;
    382       1.4    atatat 	node.sysctl_data = &t;
    383       1.4    atatat 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    384       1.4    atatat 	if (error || newp == NULL)
    385       1.4    atatat 		return (error);
    386       1.1  jonathan 
    387       1.4    atatat 	switch (rnode->sysctl_num) {
    388       1.1  jonathan 	case IPSECCTL_DEF_ESP_TRANSLEV:
    389       1.1  jonathan 	case IPSECCTL_DEF_ESP_NETLEV:
    390       1.1  jonathan 	case IPSECCTL_DEF_AH_TRANSLEV:
    391       1.1  jonathan 	case IPSECCTL_DEF_AH_NETLEV:
    392      1.13     perry 		if (t != IPSEC_LEVEL_USE &&
    393       1.4    atatat 		    t != IPSEC_LEVEL_REQUIRE)
    394       1.4    atatat 			return (EINVAL);
    395       1.4    atatat 		ipsec_invalpcbcacheall();
    396       1.1  jonathan 		break;
    397       1.4    atatat       	case IPSECCTL_DEF_POLICY:
    398       1.4    atatat 		if (t != IPSEC_POLICY_DISCARD &&
    399       1.4    atatat 		    t != IPSEC_POLICY_NONE)
    400       1.4    atatat 			return (EINVAL);
    401       1.4    atatat 		ipsec_invalpcbcacheall();
    402       1.1  jonathan 		break;
    403       1.4    atatat 	default:
    404       1.4    atatat 		return (EINVAL);
    405       1.1  jonathan 	}
    406       1.1  jonathan 
    407       1.4    atatat 	*(int*)rnode->sysctl_data = t;
    408       1.4    atatat 
    409       1.4    atatat 	return (0);
    410       1.4    atatat }
    411       1.4    atatat 
    412      1.16    rpaulo #ifdef IPSEC_DEBUG
    413      1.16    rpaulo static int
    414      1.16    rpaulo sysctl_fast_ipsec_test(SYSCTLFN_ARGS)
    415      1.16    rpaulo {
    416      1.16    rpaulo 	int t, error;
    417      1.16    rpaulo 	struct sysctlnode node;
    418      1.16    rpaulo 
    419      1.16    rpaulo 	node = *rnode;
    420      1.16    rpaulo 	t = *(int*)rnode->sysctl_data;
    421      1.16    rpaulo 	node.sysctl_data = &t;
    422      1.16    rpaulo 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
    423      1.16    rpaulo 	if (error || newp == NULL)
    424      1.16    rpaulo 		return (error);
    425      1.16    rpaulo 
    426      1.16    rpaulo 	if (t < 0 || t > 1)
    427      1.16    rpaulo 		return EINVAL;
    428      1.16    rpaulo 
    429      1.16    rpaulo 	if (rnode->sysctl_data == &ipsec_replay)
    430      1.16    rpaulo 		printf("fast_ipsec: Anti-Replay service %s\n",
    431      1.16    rpaulo 		    (t == 1) ? "deactivated" : "activated");
    432      1.16    rpaulo 	else if (rnode->sysctl_data == &ipsec_integrity)
    433      1.16    rpaulo 		 printf("fast_ipsec: HMAC corruption %s\n",
    434      1.16    rpaulo 		     (t == 0) ? "deactivated" : "activated");
    435      1.16    rpaulo 
    436      1.16    rpaulo 	*(int*)rnode->sysctl_data = t;
    437      1.16    rpaulo 
    438      1.16    rpaulo 	return 0;
    439      1.16    rpaulo }
    440      1.16    rpaulo #endif
    441      1.16    rpaulo 
    442       1.4    atatat /* XXX will need a different oid at parent */
    443      1.10  jonathan SYSCTL_SETUP(sysctl_net_inet_fast_ipsec_setup, "sysctl net.inet.ipsec subtree setup")
    444       1.4    atatat {
    445      1.14    atatat 	const struct sysctlnode *_ipsec;
    446      1.11    atatat 	int ipproto_ipsec;
    447       1.4    atatat 
    448       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    449       1.8    atatat 		       CTLFLAG_PERMANENT,
    450       1.4    atatat 		       CTLTYPE_NODE, "net", NULL,
    451       1.4    atatat 		       NULL, 0, NULL, 0,
    452       1.4    atatat 		       CTL_NET, CTL_EOL);
    453       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    454       1.8    atatat 		       CTLFLAG_PERMANENT,
    455       1.4    atatat 		       CTLTYPE_NODE, "inet", NULL,
    456       1.4    atatat 		       NULL, 0, NULL, 0,
    457       1.4    atatat 		       CTL_NET, PF_INET, CTL_EOL);
    458      1.10  jonathan 
    459      1.11    atatat 	/*
    460      1.11    atatat 	 * in numerical order:
    461      1.11    atatat 	 *
    462      1.11    atatat 	 * net.inet.ipip:	CTL_NET.PF_INET.IPPROTO_IPIP
    463      1.11    atatat 	 * net.inet.esp:	CTL_NET.PF_INET.IPPROTO_ESP
    464      1.11    atatat 	 * net.inet.ah:		CTL_NET.PF_INET.IPPROTO_AH
    465      1.11    atatat 	 * net.inet.ipcomp:	CTL_NET.PF_INET.IPPROTO_IPCOMP
    466      1.11    atatat 	 * net.inet.ipsec:	CTL_NET.PF_INET.CTL_CREATE
    467      1.11    atatat 	 *
    468      1.11    atatat 	 * this creates separate trees by name, but maintains that the
    469      1.11    atatat 	 * ipsec name leads to all the old leaves.
    470      1.11    atatat 	 */
    471      1.11    atatat 
    472      1.11    atatat 	/* create net.inet.ipip */
    473       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    474       1.8    atatat 		       CTLFLAG_PERMANENT,
    475      1.11    atatat 		       CTLTYPE_NODE, "ipip", NULL,
    476       1.4    atatat 		       NULL, 0, NULL, 0,
    477      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_IPIP, CTL_EOL);
    478      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    479      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    480      1.11    atatat 		       CTLTYPE_STRUCT, "ipip_stats", NULL,
    481      1.11    atatat 		       NULL, 0, &ipipstat, sizeof(ipipstat),
    482      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_IPIP,
    483      1.11    atatat 		       CTL_CREATE, CTL_EOL);
    484       1.4    atatat 
    485      1.11    atatat 	/* create net.inet.esp subtree under IPPROTO_ESP */
    486      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    487      1.11    atatat 		       CTLFLAG_PERMANENT,
    488      1.11    atatat 		       CTLTYPE_NODE, "esp", NULL,
    489      1.11    atatat 		       NULL, 0, NULL, 0,
    490      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_ESP, CTL_EOL);
    491      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    492      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    493      1.11    atatat 		       CTLTYPE_INT, "trans_deflev", NULL,
    494      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_esp_trans_deflev, 0,
    495      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_ESP,
    496      1.11    atatat 		       IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
    497      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    498      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    499      1.11    atatat 		       CTLTYPE_INT, "net_deflev", NULL,
    500      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_esp_net_deflev, 0,
    501      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_ESP,
    502      1.11    atatat 		       IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
    503       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    504      1.10  jonathan 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    505      1.11    atatat 		       CTLTYPE_STRUCT, "esp_stats", NULL,
    506      1.11    atatat 		       NULL, 0, &espstat, sizeof(espstat),
    507      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_ESP,
    508      1.11    atatat 		       CTL_CREATE, CTL_EOL);
    509      1.10  jonathan 
    510      1.11    atatat 	/* create net.inet.ah subtree under IPPROTO_AH */
    511      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    512      1.11    atatat 		       CTLFLAG_PERMANENT,
    513      1.11    atatat 		       CTLTYPE_NODE, "ah", NULL,
    514      1.11    atatat 		       NULL, 0, NULL, 0,
    515      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_AH, CTL_EOL);
    516       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    517       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    518      1.10  jonathan 		       CTLTYPE_INT, "cleartos", NULL,
    519      1.25  degroote 		       NULL, 0, &ip4_ah_cleartos, 0,
    520       1.4    atatat 		       CTL_NET, PF_INET, IPPROTO_AH,
    521      1.10  jonathan 		       IPSECCTL_AH_CLEARTOS, CTL_EOL);
    522       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    523       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    524      1.10  jonathan 		       CTLTYPE_INT, "offsetmask", NULL,
    525      1.10  jonathan 		       NULL, 0, &ip4_ah_offsetmask, 0,
    526       1.4    atatat 		       CTL_NET, PF_INET, IPPROTO_AH,
    527      1.10  jonathan 		       IPSECCTL_AH_OFFSETMASK, CTL_EOL);
    528       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    529       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    530      1.10  jonathan 		       CTLTYPE_INT, "trans_deflev", NULL,
    531       1.4    atatat 		       sysctl_fast_ipsec, 0, &ip4_ah_trans_deflev, 0,
    532      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_AH,
    533       1.4    atatat 		       IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
    534       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    535       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    536      1.10  jonathan 		       CTLTYPE_INT, "net_deflev", NULL,
    537       1.4    atatat 		       sysctl_fast_ipsec, 0, &ip4_ah_net_deflev, 0,
    538      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_AH,
    539       1.4    atatat 		       IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
    540      1.10  jonathan 	sysctl_createv(clog, 0, NULL, NULL,
    541      1.10  jonathan 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    542      1.11    atatat 		       CTLTYPE_STRUCT, "ah_stats", NULL,
    543      1.11    atatat 		       NULL, 0, &ahstat, sizeof(ahstat),
    544      1.11    atatat 		       CTL_NET, PF_INET, IPPROTO_AH,
    545      1.11    atatat 		       CTL_CREATE, CTL_EOL);
    546      1.10  jonathan 
    547      1.10  jonathan 	/* create net.inet.ipcomp */
    548      1.10  jonathan 	sysctl_createv(clog, 0, NULL, NULL,
    549      1.10  jonathan 		       CTLFLAG_PERMANENT,
    550      1.10  jonathan 		       CTLTYPE_NODE, "ipcomp", NULL,
    551      1.10  jonathan 		       NULL, 0, NULL, 0,
    552      1.10  jonathan 		       CTL_NET, PF_INET, IPPROTO_IPCOMP, CTL_EOL);
    553      1.10  jonathan 	sysctl_createv(clog, 0, NULL, NULL,
    554      1.10  jonathan 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    555      1.11    atatat 		       CTLTYPE_STRUCT, "ipcomp_stats", NULL,
    556      1.10  jonathan 		       NULL, 0, &ipcompstat, sizeof(ipcompstat),
    557      1.10  jonathan 		       CTL_NET, PF_INET, IPPROTO_IPCOMP,
    558      1.11    atatat 		       CTL_CREATE, CTL_EOL);
    559      1.10  jonathan 
    560      1.11    atatat 	/* create net.inet.ipsec subtree under dynamic oid */
    561      1.11    atatat 	sysctl_createv(clog, 0, NULL, &_ipsec,
    562      1.10  jonathan 		       CTLFLAG_PERMANENT,
    563      1.10  jonathan 		       CTLTYPE_NODE, "ipsec", NULL,
    564      1.10  jonathan 		       NULL, 0, NULL, 0,
    565      1.11    atatat 		       CTL_NET, PF_INET, CTL_CREATE, CTL_EOL);
    566      1.11    atatat 	ipproto_ipsec = (_ipsec != NULL) ? _ipsec->sysctl_num : 0;
    567      1.10  jonathan 
    568       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    569       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    570      1.10  jonathan 		       CTLTYPE_INT, "def_policy", NULL,
    571      1.10  jonathan 		       sysctl_fast_ipsec, 0, &ip4_def_policy.policy, 0,
    572      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    573      1.10  jonathan 		       IPSECCTL_DEF_POLICY, CTL_EOL);
    574       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    575       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    576      1.11    atatat 		       CTLTYPE_INT, "esp_trans_deflev", NULL,
    577      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_esp_trans_deflev, 0,
    578      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    579      1.11    atatat 		       IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
    580      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    581      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    582      1.11    atatat 		       CTLTYPE_INT, "esp_net_deflev", NULL,
    583      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_esp_net_deflev, 0,
    584      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    585      1.11    atatat 		       IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
    586      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    587      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    588      1.11    atatat 		       CTLTYPE_INT, "ah_trans_deflev", NULL,
    589      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_ah_trans_deflev, 0,
    590      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    591      1.11    atatat 		       IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
    592      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    593      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    594      1.11    atatat 		       CTLTYPE_INT, "ah_net_deflev", NULL,
    595      1.11    atatat 		       sysctl_fast_ipsec, 0, &ip4_ah_net_deflev, 0,
    596      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    597      1.11    atatat 		       IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
    598      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    599      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    600      1.11    atatat 		       CTLTYPE_INT, "ah_cleartos", NULL,
    601      1.25  degroote 		       NULL, 0, &ip4_ah_cleartos, 0,
    602      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    603      1.11    atatat 		       IPSECCTL_AH_CLEARTOS, CTL_EOL);
    604      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    605      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    606      1.11    atatat 		       CTLTYPE_INT, "ah_offsetmask", NULL,
    607      1.11    atatat 		       NULL, 0, &ip4_ah_offsetmask, 0,
    608      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    609      1.11    atatat 		       IPSECCTL_AH_OFFSETMASK, CTL_EOL);
    610      1.11    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    611      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    612       1.4    atatat 		       CTLTYPE_INT, "dfbit", NULL,
    613       1.4    atatat 		       NULL, 0, &ip4_ipsec_dfbit, 0,
    614      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    615       1.4    atatat 		       IPSECCTL_DFBIT, CTL_EOL);
    616       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    617       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    618       1.4    atatat 		       CTLTYPE_INT, "ecn", NULL,
    619       1.4    atatat 		       NULL, 0, &ip4_ipsec_ecn, 0,
    620      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    621       1.4    atatat 		       IPSECCTL_ECN, CTL_EOL);
    622       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    623       1.8    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    624       1.4    atatat 		       CTLTYPE_INT, "debug", NULL,
    625       1.4    atatat 		       NULL, 0, &ipsec_debug, 0,
    626      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    627       1.4    atatat 		       IPSECCTL_DEBUG, CTL_EOL);
    628       1.8    atatat 	sysctl_createv(clog, 0, NULL, NULL,
    629      1.11    atatat 		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
    630      1.11    atatat 		       CTLTYPE_STRUCT, "ipsecstats", NULL,
    631      1.11    atatat 		       NULL, 0, &ipsecstat, sizeof(ipsecstat),
    632      1.11    atatat 		       CTL_NET, PF_INET, ipproto_ipsec,
    633      1.11    atatat 		       CTL_CREATE, CTL_EOL);
    634      1.16    rpaulo #ifdef IPSEC_DEBUG
    635      1.16    rpaulo 	sysctl_createv(clog, 0, NULL, NULL,
    636      1.16    rpaulo 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    637      1.16    rpaulo 		       CTLTYPE_INT, "test_replay",
    638      1.16    rpaulo 		       SYSCTL_DESCR("Emulate replay attack"),
    639      1.16    rpaulo 		       sysctl_fast_ipsec_test, 0, &ipsec_replay, 0,
    640      1.16    rpaulo 		       CTL_NET, PF_INET, ipproto_ipsec,
    641      1.16    rpaulo 		       CTL_CREATE, CTL_EOL);
    642      1.16    rpaulo 	sysctl_createv(clog, 0, NULL, NULL,
    643      1.16    rpaulo 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    644      1.16    rpaulo 		       CTLTYPE_INT, "test_integrity",
    645      1.16    rpaulo 		       SYSCTL_DESCR("Emulate man-in-the-middle attack"),
    646      1.16    rpaulo 		       sysctl_fast_ipsec_test, 0, &ipsec_integrity, 0,
    647      1.16    rpaulo 		       CTL_NET, PF_INET, ipproto_ipsec,
    648      1.16    rpaulo 		       CTL_CREATE, CTL_EOL);
    649      1.16    rpaulo #endif
    650       1.1  jonathan }
    651      1.26  degroote 
    652      1.26  degroote #ifdef INET6
    653      1.26  degroote SYSCTL_SETUP(sysctl_net_inet6_fast_ipsec6_setup,
    654      1.26  degroote 	     "sysctl net.inet6.ipsec6 subtree setup")
    655      1.26  degroote {
    656      1.26  degroote 
    657      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    658      1.26  degroote 		       CTLFLAG_PERMANENT,
    659      1.26  degroote 		       CTLTYPE_NODE, "net", NULL,
    660      1.26  degroote 		       NULL, 0, NULL, 0,
    661      1.26  degroote 		       CTL_NET, CTL_EOL);
    662      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    663      1.26  degroote 		       CTLFLAG_PERMANENT,
    664      1.26  degroote 		       CTLTYPE_NODE, "inet6", NULL,
    665      1.26  degroote 		       NULL, 0, NULL, 0,
    666      1.26  degroote 		       CTL_NET, PF_INET6, CTL_EOL);
    667      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    668      1.26  degroote 		       CTLFLAG_PERMANENT,
    669      1.26  degroote 		       CTLTYPE_NODE, "ipsec6",
    670      1.26  degroote 		       SYSCTL_DESCR("IPv6 related IPSec settings"),
    671      1.26  degroote 		       NULL, 0, NULL, 0,
    672      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH, CTL_EOL);
    673      1.26  degroote 
    674      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    675      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    676      1.26  degroote 		       CTLTYPE_STRUCT, "stats",
    677      1.26  degroote 		       SYSCTL_DESCR("IPSec statistics and counters"),
    678      1.26  degroote 		       NULL, 0, &ipsec6stat, sizeof(ipsec6stat),
    679      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    680      1.26  degroote 		       IPSECCTL_STATS, CTL_EOL);
    681      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    682      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    683      1.26  degroote 		       CTLTYPE_INT, "def_policy",
    684      1.26  degroote 		       SYSCTL_DESCR("Default action for non-IPSec packets"),
    685      1.26  degroote 		       sysctl_fast_ipsec, 0, &ip6_def_policy, 0,
    686      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    687      1.26  degroote 		       IPSECCTL_DEF_POLICY, CTL_EOL);
    688      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    689      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    690      1.26  degroote 		       CTLTYPE_INT, "esp_trans_deflev",
    691      1.26  degroote 		       SYSCTL_DESCR("Default required security level for "
    692      1.26  degroote 				    "transport mode traffic"),
    693      1.26  degroote 		       sysctl_fast_ipsec, 0, &ip6_esp_trans_deflev, 0,
    694      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    695      1.26  degroote 		       IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
    696      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    697      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    698      1.26  degroote 		       CTLTYPE_INT, "esp_net_deflev",
    699      1.26  degroote 		       SYSCTL_DESCR("Default required security level for "
    700      1.26  degroote 				    "tunneled traffic"),
    701      1.26  degroote 		       sysctl_fast_ipsec, 0, &ip6_esp_net_deflev, 0,
    702      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    703      1.26  degroote 		       IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
    704      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    705      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    706      1.26  degroote 		       CTLTYPE_INT, "ah_trans_deflev",
    707      1.26  degroote 		       SYSCTL_DESCR("Default required security level for "
    708      1.26  degroote 				    "transport mode headers"),
    709      1.26  degroote 		       sysctl_fast_ipsec, 0, &ip6_ah_trans_deflev, 0,
    710      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    711      1.26  degroote 		       IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
    712      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    713      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    714      1.26  degroote 		       CTLTYPE_INT, "ah_net_deflev",
    715      1.26  degroote 		       SYSCTL_DESCR("Default required security level for "
    716      1.26  degroote 				    "tunneled headers"),
    717      1.26  degroote 		       sysctl_fast_ipsec, 0, &ip6_ah_net_deflev, 0,
    718      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    719      1.26  degroote 		       IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
    720      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    721      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    722      1.26  degroote 		       CTLTYPE_INT, "ecn",
    723      1.26  degroote 		       SYSCTL_DESCR("Behavior of ECN for tunneled traffic"),
    724      1.26  degroote 		       NULL, 0, &ip6_ipsec_ecn, 0,
    725      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    726      1.26  degroote 		       IPSECCTL_ECN, CTL_EOL);
    727      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    728      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    729      1.26  degroote 		       CTLTYPE_INT, "debug",
    730      1.26  degroote 		       SYSCTL_DESCR("Enable IPSec debugging output"),
    731      1.26  degroote 		       NULL, 0, &ipsec_debug, 0,
    732      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_AH,
    733      1.26  degroote 		       IPSECCTL_DEBUG, CTL_EOL);
    734      1.26  degroote 
    735      1.26  degroote 	/*
    736      1.26  degroote 	 * "aliases" for the ipsec6 subtree
    737      1.26  degroote 	 */
    738      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    739      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
    740      1.26  degroote 		       CTLTYPE_NODE, "esp6", NULL,
    741      1.26  degroote 		       NULL, IPPROTO_AH, NULL, 0,
    742      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_ESP, CTL_EOL);
    743      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    744      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
    745      1.26  degroote 		       CTLTYPE_NODE, "ipcomp6", NULL,
    746      1.26  degroote 		       NULL, IPPROTO_AH, NULL, 0,
    747      1.26  degroote 		       CTL_NET, PF_INET6, IPPROTO_IPCOMP, CTL_EOL);
    748      1.26  degroote 	sysctl_createv(clog, 0, NULL, NULL,
    749      1.26  degroote 		       CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
    750      1.26  degroote 		       CTLTYPE_NODE, "ah6", NULL,
    751      1.26  degroote 		       NULL, IPPROTO_AH, NULL, 0,
    752      1.26  degroote 		       CTL_NET, PF_INET6, CTL_CREATE, CTL_EOL);
    753      1.26  degroote }
    754      1.26  degroote #endif /* INET6 */
    755