ipsec_netbsd.c revision 1.38 1 1.38 msaitoh /* $NetBSD: ipsec_netbsd.c,v 1.38 2016/07/07 06:55:43 msaitoh 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.38 msaitoh __KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.38 2016/07/07 06:55:43 msaitoh 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.29 ad #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.30 thorpej #include <netipsec/ipsec_private.h>
69 1.3 tls #include <netipsec/key.h>
70 1.3 tls #include <netipsec/keydb.h>
71 1.3 tls #include <netipsec/key_debug.h>
72 1.18 degroote #include <netipsec/ah.h>
73 1.1 jonathan #include <netipsec/ah_var.h>
74 1.5 jonathan #include <netipsec/esp.h>
75 1.10 jonathan #include <netipsec/esp_var.h>
76 1.10 jonathan #include <netipsec/ipip_var.h>
77 1.10 jonathan #include <netipsec/ipcomp_var.h>
78 1.5 jonathan
79 1.5 jonathan #ifdef INET6
80 1.5 jonathan #include <netipsec/ipsec6.h>
81 1.5 jonathan #include <netinet6/ip6protosw.h>
82 1.5 jonathan #include <netinet/icmp6.h>
83 1.1 jonathan #endif
84 1.1 jonathan
85 1.3 tls #include <netipsec/key.h>
86 1.1 jonathan
87 1.1 jonathan /* assumes that ip header and ah header are contiguous on mbuf */
88 1.20 degroote void*
89 1.28 degroote ah4_ctlinput(int cmd, const struct sockaddr *sa, void *v)
90 1.1 jonathan {
91 1.1 jonathan struct ip *ip = v;
92 1.1 jonathan struct ah *ah;
93 1.1 jonathan struct icmp *icp;
94 1.1 jonathan struct secasvar *sav;
95 1.1 jonathan
96 1.1 jonathan if (sa->sa_family != AF_INET ||
97 1.18 degroote sa->sa_len != sizeof(struct sockaddr_in))
98 1.38 msaitoh return NULL;
99 1.1 jonathan if ((unsigned)cmd >= PRC_NCMDS)
100 1.1 jonathan return NULL;
101 1.20 degroote
102 1.1 jonathan if (cmd == PRC_MSGSIZE && ip_mtudisc && ip && ip->ip_v == 4) {
103 1.1 jonathan /*
104 1.1 jonathan * Check to see if we have a valid SA corresponding to
105 1.1 jonathan * the address in the ICMP message payload.
106 1.1 jonathan */
107 1.23 degroote ah = (struct ah *)((char *)ip + (ip->ip_hl << 2));
108 1.20 degroote sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
109 1.27 degroote IPPROTO_AH, ah->ah_spi, 0, 0);
110 1.1 jonathan
111 1.20 degroote if (sav) {
112 1.20 degroote if (sav->state == SADB_SASTATE_MATURE ||
113 1.20 degroote sav->state == SADB_SASTATE_DYING) {
114 1.20 degroote
115 1.20 degroote /*
116 1.20 degroote * Now that we've validated that we are actually
117 1.20 degroote * communicating with the host indicated in the
118 1.20 degroote * ICMP message, locate the ICMP header,
119 1.20 degroote * recalculate the new MTU, and create the
120 1.20 degroote * corresponding routing entry.
121 1.20 degroote */
122 1.23 degroote icp = (struct icmp *)((char *)ip -
123 1.20 degroote offsetof(struct icmp, icmp_ip));
124 1.20 degroote icmp_mtudisc(icp, ip->ip_dst);
125 1.1 jonathan
126 1.20 degroote }
127 1.21 degroote KEY_FREESAV(&sav);
128 1.20 degroote }
129 1.1 jonathan }
130 1.1 jonathan return NULL;
131 1.1 jonathan }
132 1.1 jonathan
133 1.20 degroote
134 1.20 degroote
135 1.1 jonathan /* assumes that ip header and esp header are contiguous on mbuf */
136 1.20 degroote void*
137 1.28 degroote esp4_ctlinput(int cmd, const struct sockaddr *sa, void *v)
138 1.1 jonathan {
139 1.1 jonathan struct ip *ip = v;
140 1.1 jonathan struct esp *esp;
141 1.1 jonathan struct icmp *icp;
142 1.1 jonathan struct secasvar *sav;
143 1.1 jonathan
144 1.1 jonathan if (sa->sa_family != AF_INET ||
145 1.1 jonathan sa->sa_len != sizeof(struct sockaddr_in))
146 1.1 jonathan return NULL;
147 1.1 jonathan if ((unsigned)cmd >= PRC_NCMDS)
148 1.1 jonathan return NULL;
149 1.20 degroote
150 1.1 jonathan if (cmd == PRC_MSGSIZE && ip_mtudisc && ip && ip->ip_v == 4) {
151 1.1 jonathan /*
152 1.1 jonathan * Check to see if we have a valid SA corresponding to
153 1.1 jonathan * the address in the ICMP message payload.
154 1.1 jonathan */
155 1.23 degroote esp = (struct esp *)((char *)ip + (ip->ip_hl << 2));
156 1.20 degroote sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
157 1.27 degroote IPPROTO_ESP, esp->esp_spi, 0, 0);
158 1.1 jonathan
159 1.20 degroote if (sav) {
160 1.20 degroote if (sav->state == SADB_SASTATE_MATURE ||
161 1.20 degroote sav->state == SADB_SASTATE_DYING) {
162 1.20 degroote
163 1.20 degroote /*
164 1.20 degroote * Now that we've validated that we are actually
165 1.20 degroote * communicating with the host indicated in the
166 1.20 degroote * ICMP message, locate the ICMP header,
167 1.20 degroote * recalculate the new MTU, and create the
168 1.20 degroote * corresponding routing entry.
169 1.20 degroote */
170 1.20 degroote
171 1.23 degroote icp = (struct icmp *)((char *)ip -
172 1.20 degroote offsetof(struct icmp, icmp_ip));
173 1.20 degroote icmp_mtudisc(icp, ip->ip_dst);
174 1.1 jonathan
175 1.20 degroote }
176 1.21 degroote KEY_FREESAV(&sav);
177 1.20 degroote }
178 1.1 jonathan }
179 1.1 jonathan return NULL;
180 1.1 jonathan }
181 1.1 jonathan
182 1.1 jonathan #ifdef INET6
183 1.31 degroote void *
184 1.28 degroote ah6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
185 1.18 degroote {
186 1.18 degroote const struct newah *ahp;
187 1.18 degroote struct newah ah;
188 1.18 degroote struct secasvar *sav;
189 1.18 degroote struct ip6_hdr *ip6;
190 1.18 degroote struct mbuf *m;
191 1.18 degroote struct ip6ctlparam *ip6cp = NULL;
192 1.18 degroote int off;
193 1.18 degroote
194 1.18 degroote if (sa->sa_family != AF_INET6 ||
195 1.18 degroote sa->sa_len != sizeof(struct sockaddr_in6))
196 1.31 degroote return NULL;
197 1.18 degroote if ((unsigned)cmd >= PRC_NCMDS)
198 1.31 degroote return NULL;
199 1.18 degroote
200 1.18 degroote /* if the parameter is from icmp6, decode it. */
201 1.18 degroote if (d != NULL) {
202 1.18 degroote ip6cp = (struct ip6ctlparam *)d;
203 1.18 degroote m = ip6cp->ip6c_m;
204 1.18 degroote ip6 = ip6cp->ip6c_ip6;
205 1.18 degroote off = ip6cp->ip6c_off;
206 1.18 degroote } else {
207 1.18 degroote m = NULL;
208 1.18 degroote ip6 = NULL;
209 1.18 degroote off = 0;
210 1.18 degroote }
211 1.18 degroote
212 1.18 degroote if (ip6) {
213 1.18 degroote /*
214 1.18 degroote * XXX: We assume that when ip6 is non NULL,
215 1.18 degroote * M and OFF are valid.
216 1.18 degroote */
217 1.18 degroote
218 1.18 degroote /* check if we can safely examine src and dst ports */
219 1.18 degroote if (m->m_pkthdr.len < off + sizeof(ah))
220 1.31 degroote return NULL;
221 1.18 degroote
222 1.18 degroote if (m->m_len < off + sizeof(ah)) {
223 1.18 degroote /*
224 1.18 degroote * this should be rare case,
225 1.18 degroote * so we compromise on this copy...
226 1.18 degroote */
227 1.24 degroote m_copydata(m, off, sizeof(ah), &ah);
228 1.18 degroote ahp = &ah;
229 1.18 degroote } else
230 1.23 degroote ahp = (struct newah *)(mtod(m, char *) + off);
231 1.18 degroote
232 1.18 degroote if (cmd == PRC_MSGSIZE) {
233 1.18 degroote int valid = 0;
234 1.18 degroote
235 1.18 degroote /*
236 1.18 degroote * Check to see if we have a valid SA corresponding
237 1.18 degroote * to the address in the ICMP message payload.
238 1.18 degroote */
239 1.19 degroote sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
240 1.27 degroote IPPROTO_AH, ahp->ah_spi, 0, 0);
241 1.18 degroote
242 1.18 degroote if (sav) {
243 1.18 degroote if (sav->state == SADB_SASTATE_MATURE ||
244 1.18 degroote sav->state == SADB_SASTATE_DYING)
245 1.18 degroote valid++;
246 1.18 degroote KEY_FREESAV(&sav);
247 1.18 degroote }
248 1.18 degroote
249 1.18 degroote /* XXX Further validation? */
250 1.18 degroote
251 1.18 degroote /*
252 1.18 degroote * Depending on the value of "valid" and routing
253 1.18 degroote * table size (mtudisc_{hi,lo}wat), we will:
254 1.18 degroote * - recalcurate the new MTU and create the
255 1.18 degroote * corresponding routing entry, or
256 1.18 degroote * - ignore the MTU change notification.
257 1.18 degroote */
258 1.18 degroote icmp6_mtudisc_update((struct ip6ctlparam *)d,valid);
259 1.18 degroote }
260 1.18 degroote
261 1.18 degroote /* we normally notify single pcb here */
262 1.18 degroote } else {
263 1.18 degroote /* we normally notify any pcb here */
264 1.18 degroote }
265 1.31 degroote return NULL;
266 1.18 degroote }
267 1.18 degroote
268 1.18 degroote
269 1.18 degroote
270 1.31 degroote void *
271 1.28 degroote esp6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
272 1.1 jonathan {
273 1.1 jonathan const struct newesp *espp;
274 1.1 jonathan struct newesp esp;
275 1.1 jonathan struct ip6ctlparam *ip6cp = NULL, ip6cp1;
276 1.1 jonathan struct secasvar *sav;
277 1.1 jonathan struct ip6_hdr *ip6;
278 1.1 jonathan struct mbuf *m;
279 1.1 jonathan int off;
280 1.1 jonathan
281 1.1 jonathan if (sa->sa_family != AF_INET6 ||
282 1.1 jonathan sa->sa_len != sizeof(struct sockaddr_in6))
283 1.31 degroote return NULL;
284 1.1 jonathan if ((unsigned)cmd >= PRC_NCMDS)
285 1.31 degroote return NULL;
286 1.1 jonathan
287 1.1 jonathan /* if the parameter is from icmp6, decode it. */
288 1.1 jonathan if (d != NULL) {
289 1.1 jonathan ip6cp = (struct ip6ctlparam *)d;
290 1.1 jonathan m = ip6cp->ip6c_m;
291 1.1 jonathan ip6 = ip6cp->ip6c_ip6;
292 1.1 jonathan off = ip6cp->ip6c_off;
293 1.1 jonathan } else {
294 1.1 jonathan m = NULL;
295 1.1 jonathan ip6 = NULL;
296 1.7 jonathan off = 0;
297 1.1 jonathan }
298 1.1 jonathan
299 1.1 jonathan if (ip6) {
300 1.1 jonathan /*
301 1.1 jonathan * Notify the error to all possible sockets via pfctlinput2.
302 1.1 jonathan * Since the upper layer information (such as protocol type,
303 1.1 jonathan * source and destination ports) is embedded in the encrypted
304 1.1 jonathan * data and might have been cut, we can't directly call
305 1.1 jonathan * an upper layer ctlinput function. However, the pcbnotify
306 1.1 jonathan * function will consider source and destination addresses
307 1.1 jonathan * as well as the flow info value, and may be able to find
308 1.1 jonathan * some PCB that should be notified.
309 1.1 jonathan * Although pfctlinput2 will call esp6_ctlinput(), there is
310 1.1 jonathan * no possibility of an infinite loop of function calls,
311 1.1 jonathan * because we don't pass the inner IPv6 header.
312 1.1 jonathan */
313 1.20 degroote memset(&ip6cp1, 0, sizeof(ip6cp1));
314 1.1 jonathan ip6cp1.ip6c_src = ip6cp->ip6c_src;
315 1.24 degroote pfctlinput2(cmd, sa, &ip6cp1);
316 1.1 jonathan
317 1.1 jonathan /*
318 1.1 jonathan * Then go to special cases that need ESP header information.
319 1.1 jonathan * XXX: We assume that when ip6 is non NULL,
320 1.1 jonathan * M and OFF are valid.
321 1.1 jonathan */
322 1.1 jonathan
323 1.1 jonathan /* check if we can safely examine src and dst ports */
324 1.1 jonathan if (m->m_pkthdr.len < off + sizeof(esp))
325 1.31 degroote return NULL;
326 1.1 jonathan
327 1.1 jonathan if (m->m_len < off + sizeof(esp)) {
328 1.1 jonathan /*
329 1.1 jonathan * this should be rare case,
330 1.1 jonathan * so we compromise on this copy...
331 1.1 jonathan */
332 1.24 degroote m_copydata(m, off, sizeof(esp), &esp);
333 1.1 jonathan espp = &esp;
334 1.1 jonathan } else
335 1.23 degroote espp = (struct newesp*)(mtod(m, char *) + off);
336 1.1 jonathan
337 1.1 jonathan if (cmd == PRC_MSGSIZE) {
338 1.1 jonathan int valid = 0;
339 1.1 jonathan
340 1.1 jonathan /*
341 1.1 jonathan * Check to see if we have a valid SA corresponding to
342 1.1 jonathan * the address in the ICMP message payload.
343 1.1 jonathan */
344 1.19 degroote
345 1.19 degroote sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
346 1.27 degroote IPPROTO_ESP, espp->esp_spi, 0, 0);
347 1.7 jonathan
348 1.1 jonathan if (sav) {
349 1.1 jonathan if (sav->state == SADB_SASTATE_MATURE ||
350 1.1 jonathan sav->state == SADB_SASTATE_DYING)
351 1.1 jonathan valid++;
352 1.7 jonathan KEY_FREESAV(&sav);
353 1.1 jonathan }
354 1.1 jonathan
355 1.1 jonathan /* XXX Further validation? */
356 1.1 jonathan
357 1.1 jonathan /*
358 1.1 jonathan * Depending on the value of "valid" and routing table
359 1.1 jonathan * size (mtudisc_{hi,lo}wat), we will:
360 1.1 jonathan * - recalcurate the new MTU and create the
361 1.1 jonathan * corresponding routing entry, or
362 1.1 jonathan * - ignore the MTU change notification.
363 1.1 jonathan */
364 1.1 jonathan icmp6_mtudisc_update((struct ip6ctlparam *)d, valid);
365 1.1 jonathan }
366 1.1 jonathan } else {
367 1.1 jonathan /* we normally notify any pcb here */
368 1.1 jonathan }
369 1.31 degroote return NULL;
370 1.1 jonathan }
371 1.1 jonathan #endif /* INET6 */
372 1.1 jonathan
373 1.4 atatat static int
374 1.35 christos sysctl_ipsec(SYSCTLFN_ARGS)
375 1.1 jonathan {
376 1.4 atatat int error, t;
377 1.4 atatat struct sysctlnode node;
378 1.4 atatat
379 1.4 atatat node = *rnode;
380 1.4 atatat t = *(int*)rnode->sysctl_data;
381 1.4 atatat node.sysctl_data = &t;
382 1.4 atatat error = sysctl_lookup(SYSCTLFN_CALL(&node));
383 1.4 atatat if (error || newp == NULL)
384 1.4 atatat return (error);
385 1.1 jonathan
386 1.4 atatat switch (rnode->sysctl_num) {
387 1.1 jonathan case IPSECCTL_DEF_ESP_TRANSLEV:
388 1.1 jonathan case IPSECCTL_DEF_ESP_NETLEV:
389 1.1 jonathan case IPSECCTL_DEF_AH_TRANSLEV:
390 1.1 jonathan case IPSECCTL_DEF_AH_NETLEV:
391 1.13 perry if (t != IPSEC_LEVEL_USE &&
392 1.4 atatat t != IPSEC_LEVEL_REQUIRE)
393 1.4 atatat return (EINVAL);
394 1.4 atatat ipsec_invalpcbcacheall();
395 1.1 jonathan break;
396 1.4 atatat case IPSECCTL_DEF_POLICY:
397 1.4 atatat if (t != IPSEC_POLICY_DISCARD &&
398 1.4 atatat t != IPSEC_POLICY_NONE)
399 1.4 atatat return (EINVAL);
400 1.4 atatat ipsec_invalpcbcacheall();
401 1.1 jonathan break;
402 1.4 atatat default:
403 1.4 atatat return (EINVAL);
404 1.1 jonathan }
405 1.1 jonathan
406 1.4 atatat *(int*)rnode->sysctl_data = t;
407 1.4 atatat
408 1.4 atatat return (0);
409 1.4 atatat }
410 1.4 atatat
411 1.16 rpaulo #ifdef IPSEC_DEBUG
412 1.16 rpaulo static int
413 1.35 christos sysctl_ipsec_test(SYSCTLFN_ARGS)
414 1.16 rpaulo {
415 1.16 rpaulo int t, error;
416 1.16 rpaulo struct sysctlnode node;
417 1.16 rpaulo
418 1.38 msaitoh node = *rnode;
419 1.16 rpaulo t = *(int*)rnode->sysctl_data;
420 1.16 rpaulo node.sysctl_data = &t;
421 1.16 rpaulo error = sysctl_lookup(SYSCTLFN_CALL(&node));
422 1.16 rpaulo if (error || newp == NULL)
423 1.16 rpaulo return (error);
424 1.16 rpaulo
425 1.16 rpaulo if (t < 0 || t > 1)
426 1.16 rpaulo return EINVAL;
427 1.16 rpaulo
428 1.16 rpaulo if (rnode->sysctl_data == &ipsec_replay)
429 1.35 christos printf("ipsec: Anti-Replay service %s\n",
430 1.16 rpaulo (t == 1) ? "deactivated" : "activated");
431 1.16 rpaulo else if (rnode->sysctl_data == &ipsec_integrity)
432 1.35 christos printf("ipsec: HMAC corruption %s\n",
433 1.16 rpaulo (t == 0) ? "deactivated" : "activated");
434 1.16 rpaulo
435 1.16 rpaulo *(int*)rnode->sysctl_data = t;
436 1.16 rpaulo
437 1.16 rpaulo return 0;
438 1.16 rpaulo }
439 1.16 rpaulo #endif
440 1.16 rpaulo
441 1.30 thorpej static int
442 1.35 christos sysctl_net_inet_ipsec_stats(SYSCTLFN_ARGS)
443 1.30 thorpej {
444 1.30 thorpej
445 1.32 thorpej return (NETSTAT_SYSCTL(ipsecstat_percpu, IPSEC_NSTATS));
446 1.30 thorpej }
447 1.30 thorpej
448 1.30 thorpej static int
449 1.30 thorpej sysctl_net_inet_ah_stats(SYSCTLFN_ARGS)
450 1.30 thorpej {
451 1.30 thorpej
452 1.32 thorpej return (NETSTAT_SYSCTL(ahstat_percpu, AH_NSTATS));
453 1.30 thorpej }
454 1.30 thorpej
455 1.30 thorpej static int
456 1.30 thorpej sysctl_net_inet_esp_stats(SYSCTLFN_ARGS)
457 1.30 thorpej {
458 1.30 thorpej
459 1.32 thorpej return (NETSTAT_SYSCTL(espstat_percpu, ESP_NSTATS));
460 1.30 thorpej }
461 1.30 thorpej
462 1.30 thorpej static int
463 1.30 thorpej sysctl_net_inet_ipcomp_stats(SYSCTLFN_ARGS)
464 1.30 thorpej {
465 1.30 thorpej
466 1.32 thorpej return (NETSTAT_SYSCTL(ipcompstat_percpu, IPCOMP_NSTATS));
467 1.30 thorpej }
468 1.30 thorpej
469 1.30 thorpej static int
470 1.30 thorpej sysctl_net_inet_ipip_stats(SYSCTLFN_ARGS)
471 1.30 thorpej {
472 1.30 thorpej
473 1.32 thorpej return (NETSTAT_SYSCTL(ipipstat_percpu, IPIP_NSTATS));
474 1.30 thorpej }
475 1.30 thorpej
476 1.37 christos static int
477 1.37 christos sysctl_net_ipsec_enabled(SYSCTLFN_ARGS)
478 1.37 christos {
479 1.37 christos int newenabled, error;
480 1.37 christos struct sysctlnode node;
481 1.37 christos node = *rnode;
482 1.37 christos node.sysctl_data = &newenabled;
483 1.37 christos
484 1.37 christos newenabled = ipsec_enabled;
485 1.37 christos error = sysctl_lookup(SYSCTLFN_CALL(&node));
486 1.37 christos if (error || newp == NULL)
487 1.37 christos return error;
488 1.37 christos
489 1.37 christos switch (newenabled) {
490 1.37 christos case 0:
491 1.37 christos if (key_get_used())
492 1.37 christos return EBUSY;
493 1.37 christos /*FALLTHROUGH*/
494 1.37 christos case 1:
495 1.37 christos case 2:
496 1.37 christos ipsec_enabled = newenabled;
497 1.37 christos key_update_used();
498 1.37 christos return 0;
499 1.37 christos default:
500 1.37 christos return EINVAL;
501 1.37 christos }
502 1.37 christos }
503 1.37 christos
504 1.4 atatat /* XXX will need a different oid at parent */
505 1.35 christos SYSCTL_SETUP(sysctl_net_inet_ipsec_setup, "sysctl net.inet.ipsec subtree setup")
506 1.4 atatat {
507 1.14 atatat const struct sysctlnode *_ipsec;
508 1.11 atatat int ipproto_ipsec;
509 1.4 atatat
510 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
511 1.8 atatat CTLFLAG_PERMANENT,
512 1.4 atatat CTLTYPE_NODE, "inet", NULL,
513 1.4 atatat NULL, 0, NULL, 0,
514 1.4 atatat CTL_NET, PF_INET, CTL_EOL);
515 1.10 jonathan
516 1.11 atatat /*
517 1.11 atatat * in numerical order:
518 1.11 atatat *
519 1.11 atatat * net.inet.ipip: CTL_NET.PF_INET.IPPROTO_IPIP
520 1.11 atatat * net.inet.esp: CTL_NET.PF_INET.IPPROTO_ESP
521 1.11 atatat * net.inet.ah: CTL_NET.PF_INET.IPPROTO_AH
522 1.11 atatat * net.inet.ipcomp: CTL_NET.PF_INET.IPPROTO_IPCOMP
523 1.11 atatat * net.inet.ipsec: CTL_NET.PF_INET.CTL_CREATE
524 1.11 atatat *
525 1.11 atatat * this creates separate trees by name, but maintains that the
526 1.11 atatat * ipsec name leads to all the old leaves.
527 1.11 atatat */
528 1.11 atatat
529 1.11 atatat /* create net.inet.ipip */
530 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
531 1.8 atatat CTLFLAG_PERMANENT,
532 1.11 atatat CTLTYPE_NODE, "ipip", NULL,
533 1.4 atatat NULL, 0, NULL, 0,
534 1.11 atatat CTL_NET, PF_INET, IPPROTO_IPIP, CTL_EOL);
535 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
536 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READONLY,
537 1.11 atatat CTLTYPE_STRUCT, "ipip_stats", NULL,
538 1.30 thorpej sysctl_net_inet_ipip_stats, 0, NULL, 0,
539 1.11 atatat CTL_NET, PF_INET, IPPROTO_IPIP,
540 1.11 atatat CTL_CREATE, CTL_EOL);
541 1.4 atatat
542 1.11 atatat /* create net.inet.esp subtree under IPPROTO_ESP */
543 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
544 1.11 atatat CTLFLAG_PERMANENT,
545 1.11 atatat CTLTYPE_NODE, "esp", NULL,
546 1.11 atatat NULL, 0, NULL, 0,
547 1.11 atatat CTL_NET, PF_INET, IPPROTO_ESP, CTL_EOL);
548 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
549 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
550 1.11 atatat CTLTYPE_INT, "trans_deflev", NULL,
551 1.35 christos sysctl_ipsec, 0, &ip4_esp_trans_deflev, 0,
552 1.11 atatat CTL_NET, PF_INET, IPPROTO_ESP,
553 1.11 atatat IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
554 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
555 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
556 1.11 atatat CTLTYPE_INT, "net_deflev", NULL,
557 1.35 christos sysctl_ipsec, 0, &ip4_esp_net_deflev, 0,
558 1.11 atatat CTL_NET, PF_INET, IPPROTO_ESP,
559 1.11 atatat IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
560 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
561 1.10 jonathan CTLFLAG_PERMANENT|CTLFLAG_READONLY,
562 1.11 atatat CTLTYPE_STRUCT, "esp_stats", NULL,
563 1.30 thorpej sysctl_net_inet_esp_stats, 0, NULL, 0,
564 1.11 atatat CTL_NET, PF_INET, IPPROTO_ESP,
565 1.11 atatat CTL_CREATE, CTL_EOL);
566 1.10 jonathan
567 1.11 atatat /* create net.inet.ah subtree under IPPROTO_AH */
568 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
569 1.11 atatat CTLFLAG_PERMANENT,
570 1.11 atatat CTLTYPE_NODE, "ah", NULL,
571 1.11 atatat NULL, 0, NULL, 0,
572 1.11 atatat CTL_NET, PF_INET, IPPROTO_AH, CTL_EOL);
573 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
574 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
575 1.10 jonathan CTLTYPE_INT, "cleartos", NULL,
576 1.25 degroote NULL, 0, &ip4_ah_cleartos, 0,
577 1.4 atatat CTL_NET, PF_INET, IPPROTO_AH,
578 1.10 jonathan IPSECCTL_AH_CLEARTOS, CTL_EOL);
579 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
580 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
581 1.10 jonathan CTLTYPE_INT, "offsetmask", NULL,
582 1.10 jonathan NULL, 0, &ip4_ah_offsetmask, 0,
583 1.4 atatat CTL_NET, PF_INET, IPPROTO_AH,
584 1.10 jonathan IPSECCTL_AH_OFFSETMASK, CTL_EOL);
585 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
586 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
587 1.10 jonathan CTLTYPE_INT, "trans_deflev", NULL,
588 1.35 christos sysctl_ipsec, 0, &ip4_ah_trans_deflev, 0,
589 1.11 atatat CTL_NET, PF_INET, IPPROTO_AH,
590 1.4 atatat IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
591 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
592 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
593 1.10 jonathan CTLTYPE_INT, "net_deflev", NULL,
594 1.35 christos sysctl_ipsec, 0, &ip4_ah_net_deflev, 0,
595 1.11 atatat CTL_NET, PF_INET, IPPROTO_AH,
596 1.4 atatat IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
597 1.10 jonathan sysctl_createv(clog, 0, NULL, NULL,
598 1.10 jonathan CTLFLAG_PERMANENT|CTLFLAG_READONLY,
599 1.11 atatat CTLTYPE_STRUCT, "ah_stats", NULL,
600 1.30 thorpej sysctl_net_inet_ah_stats, 0, NULL, 0,
601 1.11 atatat CTL_NET, PF_INET, IPPROTO_AH,
602 1.11 atatat CTL_CREATE, CTL_EOL);
603 1.10 jonathan
604 1.10 jonathan /* create net.inet.ipcomp */
605 1.10 jonathan sysctl_createv(clog, 0, NULL, NULL,
606 1.10 jonathan CTLFLAG_PERMANENT,
607 1.10 jonathan CTLTYPE_NODE, "ipcomp", NULL,
608 1.10 jonathan NULL, 0, NULL, 0,
609 1.10 jonathan CTL_NET, PF_INET, IPPROTO_IPCOMP, CTL_EOL);
610 1.10 jonathan sysctl_createv(clog, 0, NULL, NULL,
611 1.10 jonathan CTLFLAG_PERMANENT|CTLFLAG_READONLY,
612 1.11 atatat CTLTYPE_STRUCT, "ipcomp_stats", NULL,
613 1.30 thorpej sysctl_net_inet_ipcomp_stats, 0, NULL, 0,
614 1.10 jonathan CTL_NET, PF_INET, IPPROTO_IPCOMP,
615 1.11 atatat CTL_CREATE, CTL_EOL);
616 1.10 jonathan
617 1.11 atatat /* create net.inet.ipsec subtree under dynamic oid */
618 1.11 atatat sysctl_createv(clog, 0, NULL, &_ipsec,
619 1.10 jonathan CTLFLAG_PERMANENT,
620 1.10 jonathan CTLTYPE_NODE, "ipsec", NULL,
621 1.10 jonathan NULL, 0, NULL, 0,
622 1.11 atatat CTL_NET, PF_INET, CTL_CREATE, CTL_EOL);
623 1.11 atatat ipproto_ipsec = (_ipsec != NULL) ? _ipsec->sysctl_num : 0;
624 1.10 jonathan
625 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
626 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
627 1.10 jonathan CTLTYPE_INT, "def_policy", NULL,
628 1.35 christos sysctl_ipsec, 0, &ip4_def_policy.policy, 0,
629 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
630 1.10 jonathan IPSECCTL_DEF_POLICY, CTL_EOL);
631 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
632 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
633 1.11 atatat CTLTYPE_INT, "esp_trans_deflev", NULL,
634 1.35 christos sysctl_ipsec, 0, &ip4_esp_trans_deflev, 0,
635 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
636 1.11 atatat IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
637 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
638 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
639 1.11 atatat CTLTYPE_INT, "esp_net_deflev", NULL,
640 1.35 christos sysctl_ipsec, 0, &ip4_esp_net_deflev, 0,
641 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
642 1.11 atatat IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
643 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
644 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
645 1.11 atatat CTLTYPE_INT, "ah_trans_deflev", NULL,
646 1.35 christos sysctl_ipsec, 0, &ip4_ah_trans_deflev, 0,
647 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
648 1.11 atatat IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
649 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
650 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
651 1.11 atatat CTLTYPE_INT, "ah_net_deflev", NULL,
652 1.35 christos sysctl_ipsec, 0, &ip4_ah_net_deflev, 0,
653 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
654 1.11 atatat IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
655 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
656 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
657 1.11 atatat CTLTYPE_INT, "ah_cleartos", NULL,
658 1.25 degroote NULL, 0, &ip4_ah_cleartos, 0,
659 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
660 1.11 atatat IPSECCTL_AH_CLEARTOS, CTL_EOL);
661 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
662 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
663 1.11 atatat CTLTYPE_INT, "ah_offsetmask", NULL,
664 1.11 atatat NULL, 0, &ip4_ah_offsetmask, 0,
665 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
666 1.11 atatat IPSECCTL_AH_OFFSETMASK, CTL_EOL);
667 1.11 atatat sysctl_createv(clog, 0, NULL, NULL,
668 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
669 1.4 atatat CTLTYPE_INT, "dfbit", NULL,
670 1.4 atatat NULL, 0, &ip4_ipsec_dfbit, 0,
671 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
672 1.4 atatat IPSECCTL_DFBIT, CTL_EOL);
673 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
674 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
675 1.4 atatat CTLTYPE_INT, "ecn", NULL,
676 1.4 atatat NULL, 0, &ip4_ipsec_ecn, 0,
677 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
678 1.4 atatat IPSECCTL_ECN, CTL_EOL);
679 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
680 1.8 atatat CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
681 1.4 atatat CTLTYPE_INT, "debug", NULL,
682 1.4 atatat NULL, 0, &ipsec_debug, 0,
683 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
684 1.4 atatat IPSECCTL_DEBUG, CTL_EOL);
685 1.8 atatat sysctl_createv(clog, 0, NULL, NULL,
686 1.11 atatat CTLFLAG_PERMANENT|CTLFLAG_READONLY,
687 1.11 atatat CTLTYPE_STRUCT, "ipsecstats", NULL,
688 1.35 christos sysctl_net_inet_ipsec_stats, 0, NULL, 0,
689 1.11 atatat CTL_NET, PF_INET, ipproto_ipsec,
690 1.11 atatat CTL_CREATE, CTL_EOL);
691 1.37 christos sysctl_createv(clog, 0, NULL, NULL,
692 1.37 christos CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
693 1.37 christos CTLTYPE_INT, "enabled",
694 1.37 christos SYSCTL_DESCR("Enable IPSec processing"),
695 1.37 christos sysctl_net_ipsec_enabled, 0, NULL, 0,
696 1.37 christos CTL_NET, PF_INET, ipproto_ipsec,
697 1.37 christos CTL_CREATE, CTL_EOL);
698 1.37 christos sysctl_createv(clog, 0, NULL, NULL,
699 1.37 christos CTLFLAG_PERMANENT|CTLFLAG_READONLY,
700 1.37 christos CTLTYPE_INT, "used",
701 1.37 christos SYSCTL_DESCR("Is IPSec active?"),
702 1.37 christos NULL, 0, &ipsec_used, 0,
703 1.37 christos CTL_NET, PF_INET, ipproto_ipsec,
704 1.37 christos CTL_CREATE, CTL_EOL);
705 1.16 rpaulo #ifdef IPSEC_DEBUG
706 1.16 rpaulo sysctl_createv(clog, 0, NULL, NULL,
707 1.16 rpaulo CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
708 1.16 rpaulo CTLTYPE_INT, "test_replay",
709 1.16 rpaulo SYSCTL_DESCR("Emulate replay attack"),
710 1.35 christos sysctl_ipsec_test, 0, &ipsec_replay, 0,
711 1.16 rpaulo CTL_NET, PF_INET, ipproto_ipsec,
712 1.16 rpaulo CTL_CREATE, CTL_EOL);
713 1.16 rpaulo sysctl_createv(clog, 0, NULL, NULL,
714 1.16 rpaulo CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
715 1.16 rpaulo CTLTYPE_INT, "test_integrity",
716 1.16 rpaulo SYSCTL_DESCR("Emulate man-in-the-middle attack"),
717 1.35 christos sysctl_ipsec_test, 0, &ipsec_integrity, 0,
718 1.16 rpaulo CTL_NET, PF_INET, ipproto_ipsec,
719 1.16 rpaulo CTL_CREATE, CTL_EOL);
720 1.16 rpaulo #endif
721 1.1 jonathan }
722 1.26 degroote
723 1.26 degroote #ifdef INET6
724 1.35 christos SYSCTL_SETUP(sysctl_net_inet6_ipsec6_setup,
725 1.26 degroote "sysctl net.inet6.ipsec6 subtree setup")
726 1.26 degroote {
727 1.26 degroote
728 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
729 1.26 degroote CTLFLAG_PERMANENT,
730 1.26 degroote CTLTYPE_NODE, "inet6", NULL,
731 1.26 degroote NULL, 0, NULL, 0,
732 1.26 degroote CTL_NET, PF_INET6, CTL_EOL);
733 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
734 1.26 degroote CTLFLAG_PERMANENT,
735 1.26 degroote CTLTYPE_NODE, "ipsec6",
736 1.26 degroote SYSCTL_DESCR("IPv6 related IPSec settings"),
737 1.26 degroote NULL, 0, NULL, 0,
738 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH, CTL_EOL);
739 1.26 degroote
740 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
741 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
742 1.26 degroote CTLTYPE_STRUCT, "stats",
743 1.26 degroote SYSCTL_DESCR("IPSec statistics and counters"),
744 1.35 christos sysctl_net_inet_ipsec_stats, 0, NULL, 0,
745 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
746 1.26 degroote IPSECCTL_STATS, CTL_EOL);
747 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
748 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
749 1.26 degroote CTLTYPE_INT, "def_policy",
750 1.26 degroote SYSCTL_DESCR("Default action for non-IPSec packets"),
751 1.35 christos sysctl_ipsec, 0, (void *)&ip6_def_policy, 0,
752 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
753 1.26 degroote IPSECCTL_DEF_POLICY, CTL_EOL);
754 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
755 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
756 1.26 degroote CTLTYPE_INT, "esp_trans_deflev",
757 1.26 degroote SYSCTL_DESCR("Default required security level for "
758 1.26 degroote "transport mode traffic"),
759 1.35 christos sysctl_ipsec, 0, &ip6_esp_trans_deflev, 0,
760 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
761 1.26 degroote IPSECCTL_DEF_ESP_TRANSLEV, CTL_EOL);
762 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
763 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
764 1.26 degroote CTLTYPE_INT, "esp_net_deflev",
765 1.26 degroote SYSCTL_DESCR("Default required security level for "
766 1.26 degroote "tunneled traffic"),
767 1.35 christos sysctl_ipsec, 0, &ip6_esp_net_deflev, 0,
768 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
769 1.26 degroote IPSECCTL_DEF_ESP_NETLEV, CTL_EOL);
770 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
771 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
772 1.26 degroote CTLTYPE_INT, "ah_trans_deflev",
773 1.26 degroote SYSCTL_DESCR("Default required security level for "
774 1.26 degroote "transport mode headers"),
775 1.35 christos sysctl_ipsec, 0, &ip6_ah_trans_deflev, 0,
776 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
777 1.26 degroote IPSECCTL_DEF_AH_TRANSLEV, CTL_EOL);
778 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
779 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
780 1.26 degroote CTLTYPE_INT, "ah_net_deflev",
781 1.26 degroote SYSCTL_DESCR("Default required security level for "
782 1.26 degroote "tunneled headers"),
783 1.35 christos sysctl_ipsec, 0, &ip6_ah_net_deflev, 0,
784 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
785 1.26 degroote IPSECCTL_DEF_AH_NETLEV, CTL_EOL);
786 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
787 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
788 1.26 degroote CTLTYPE_INT, "ecn",
789 1.26 degroote SYSCTL_DESCR("Behavior of ECN for tunneled traffic"),
790 1.26 degroote NULL, 0, &ip6_ipsec_ecn, 0,
791 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
792 1.26 degroote IPSECCTL_ECN, CTL_EOL);
793 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
794 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
795 1.26 degroote CTLTYPE_INT, "debug",
796 1.26 degroote SYSCTL_DESCR("Enable IPSec debugging output"),
797 1.26 degroote NULL, 0, &ipsec_debug, 0,
798 1.26 degroote CTL_NET, PF_INET6, IPPROTO_AH,
799 1.26 degroote IPSECCTL_DEBUG, CTL_EOL);
800 1.37 christos sysctl_createv(clog, 0, NULL, NULL,
801 1.37 christos CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
802 1.37 christos CTLTYPE_INT, "enabled",
803 1.37 christos SYSCTL_DESCR("Enable IPSec processing"),
804 1.37 christos sysctl_net_ipsec_enabled, 0, NULL, 0,
805 1.37 christos CTL_NET, PF_INET6, IPPROTO_AH,
806 1.37 christos CTL_CREATE, CTL_EOL);
807 1.37 christos sysctl_createv(clog, 0, NULL, NULL,
808 1.37 christos CTLFLAG_PERMANENT|CTLFLAG_READONLY,
809 1.37 christos CTLTYPE_INT, "used",
810 1.37 christos SYSCTL_DESCR("Is IPSec active?"),
811 1.37 christos NULL, 0, &ipsec_used, 0,
812 1.37 christos CTL_NET, PF_INET6, IPPROTO_AH,
813 1.37 christos CTL_CREATE, CTL_EOL);
814 1.26 degroote /*
815 1.26 degroote * "aliases" for the ipsec6 subtree
816 1.26 degroote */
817 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
818 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
819 1.26 degroote CTLTYPE_NODE, "esp6", NULL,
820 1.26 degroote NULL, IPPROTO_AH, NULL, 0,
821 1.26 degroote CTL_NET, PF_INET6, IPPROTO_ESP, CTL_EOL);
822 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
823 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
824 1.26 degroote CTLTYPE_NODE, "ipcomp6", NULL,
825 1.26 degroote NULL, IPPROTO_AH, NULL, 0,
826 1.26 degroote CTL_NET, PF_INET6, IPPROTO_IPCOMP, CTL_EOL);
827 1.26 degroote sysctl_createv(clog, 0, NULL, NULL,
828 1.26 degroote CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
829 1.26 degroote CTLTYPE_NODE, "ah6", NULL,
830 1.26 degroote NULL, IPPROTO_AH, NULL, 0,
831 1.26 degroote CTL_NET, PF_INET6, CTL_CREATE, CTL_EOL);
832 1.26 degroote }
833 1.26 degroote #endif /* INET6 */
834