Dedup: merge ipsec4_hdrsiz and ipsec6_hdrsiz into ipsec_hdrsiz. ok ozaki-r@diff -r1.272 -r1.273 src/sys/netinet/tcp_subr.c
(maxv)
--- src/sys/netinet/tcp_subr.c 2018/01/19 07:53:01 1.272
+++ src/sys/netinet/tcp_subr.c 2018/02/26 08:50:25 1.273
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $ */ | 1 | /* $NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -81,27 +81,27 @@ | @@ -81,27 +81,27 @@ | |||
81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
88 | * SUCH DAMAGE. | 88 | * SUCH DAMAGE. | |
89 | * | 89 | * | |
90 | * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 | 90 | * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 | |
91 | */ | 91 | */ | |
92 | 92 | |||
93 | #include <sys/cdefs.h> | 93 | #include <sys/cdefs.h> | |
94 | __KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $"); | 94 | __KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $"); | |
95 | 95 | |||
96 | #ifdef _KERNEL_OPT | 96 | #ifdef _KERNEL_OPT | |
97 | #include "opt_inet.h" | 97 | #include "opt_inet.h" | |
98 | #include "opt_ipsec.h" | 98 | #include "opt_ipsec.h" | |
99 | #include "opt_inet_csum.h" | 99 | #include "opt_inet_csum.h" | |
100 | #include "opt_mbuftrace.h" | 100 | #include "opt_mbuftrace.h" | |
101 | #endif | 101 | #endif | |
102 | 102 | |||
103 | #include <sys/param.h> | 103 | #include <sys/param.h> | |
104 | #include <sys/atomic.h> | 104 | #include <sys/atomic.h> | |
105 | #include <sys/proc.h> | 105 | #include <sys/proc.h> | |
106 | #include <sys/systm.h> | 106 | #include <sys/systm.h> | |
107 | #include <sys/mbuf.h> | 107 | #include <sys/mbuf.h> | |
@@ -2341,50 +2341,50 @@ tcp_new_iss1(void *laddr, void *faddr, u | @@ -2341,50 +2341,50 @@ tcp_new_iss1(void *laddr, void *faddr, u | |||
2341 | #if defined(IPSEC) | 2341 | #if defined(IPSEC) | |
2342 | /* compute ESP/AH header size for TCP, including outer IP header. */ | 2342 | /* compute ESP/AH header size for TCP, including outer IP header. */ | |
2343 | size_t | 2343 | size_t | |
2344 | ipsec4_hdrsiz_tcp(struct tcpcb *tp) | 2344 | ipsec4_hdrsiz_tcp(struct tcpcb *tp) | |
2345 | { | 2345 | { | |
2346 | struct inpcb *inp; | 2346 | struct inpcb *inp; | |
2347 | size_t hdrsiz; | 2347 | size_t hdrsiz; | |
2348 | 2348 | |||
2349 | /* XXX mapped addr case (tp->t_in6pcb) */ | 2349 | /* XXX mapped addr case (tp->t_in6pcb) */ | |
2350 | if (!tp || !tp->t_template || !(inp = tp->t_inpcb)) | 2350 | if (!tp || !tp->t_template || !(inp = tp->t_inpcb)) | |
2351 | return 0; | 2351 | return 0; | |
2352 | switch (tp->t_family) { | 2352 | switch (tp->t_family) { | |
2353 | case AF_INET: | 2353 | case AF_INET: | |
2354 | /* XXX: should use currect direction. */ | 2354 | /* XXX: should use correct direction. */ | |
2355 | hdrsiz = ipsec4_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, inp); | 2355 | hdrsiz = ipsec_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, inp); | |
2356 | break; | 2356 | break; | |
2357 | default: | 2357 | default: | |
2358 | hdrsiz = 0; | 2358 | hdrsiz = 0; | |
2359 | break; | 2359 | break; | |
2360 | } | 2360 | } | |
2361 | 2361 | |||
2362 | return hdrsiz; | 2362 | return hdrsiz; | |
2363 | } | 2363 | } | |
2364 | 2364 | |||
2365 | #ifdef INET6 | 2365 | #ifdef INET6 | |
2366 | size_t | 2366 | size_t | |
2367 | ipsec6_hdrsiz_tcp(struct tcpcb *tp) | 2367 | ipsec6_hdrsiz_tcp(struct tcpcb *tp) | |
2368 | { | 2368 | { | |
2369 | struct in6pcb *in6p; | 2369 | struct in6pcb *in6p; | |
2370 | size_t hdrsiz; | 2370 | size_t hdrsiz; | |
2371 | 2371 | |||
2372 | if (!tp || !tp->t_template || !(in6p = tp->t_in6pcb)) | 2372 | if (!tp || !tp->t_template || !(in6p = tp->t_in6pcb)) | |
2373 | return 0; | 2373 | return 0; | |
2374 | switch (tp->t_family) { | 2374 | switch (tp->t_family) { | |
2375 | case AF_INET6: | 2375 | case AF_INET6: | |
2376 | /* XXX: should use currect direction. */ | 2376 | /* XXX: should use correct direction. */ | |
2377 | hdrsiz = ipsec6_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, in6p); | 2377 | hdrsiz = ipsec_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, in6p); | |
2378 | break; | 2378 | break; | |
2379 | case AF_INET: | 2379 | case AF_INET: | |
2380 | /* mapped address case - tricky */ | 2380 | /* mapped address case - tricky */ | |
2381 | default: | 2381 | default: | |
2382 | hdrsiz = 0; | 2382 | hdrsiz = 0; | |
2383 | break; | 2383 | break; | |
2384 | } | 2384 | } | |
2385 | 2385 | |||
2386 | return hdrsiz; | 2386 | return hdrsiz; | |
2387 | } | 2387 | } | |
2388 | #endif | 2388 | #endif | |
2389 | #endif /*IPSEC*/ | 2389 | #endif /*IPSEC*/ | |
2390 | 2390 |
--- src/sys/netipsec/ipsec.c 2018/02/26 08:42:16 1.137
+++ src/sys/netipsec/ipsec.c 2018/02/26 08:50:25 1.138
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ipsec.c,v 1.137 2018/02/26 08:42:16 maxv Exp $ */ | 1 | /* $NetBSD: ipsec.c,v 1.138 2018/02/26 08:50:25 maxv Exp $ */ | |
2 | /* $FreeBSD: src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */ | 2 | /* $FreeBSD: src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */ | |
3 | /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */ | 3 | /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | 31 | * SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.137 2018/02/26 08:42:16 maxv Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.138 2018/02/26 08:50:25 maxv Exp $"); | |
36 | 36 | |||
37 | /* | 37 | /* | |
38 | * IPsec controller part. | 38 | * IPsec controller part. | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #if defined(_KERNEL_OPT) | 41 | #if defined(_KERNEL_OPT) | |
42 | #include "opt_inet.h" | 42 | #include "opt_inet.h" | |
43 | #include "opt_ipsec.h" | 43 | #include "opt_ipsec.h" | |
44 | #endif | 44 | #endif | |
45 | 45 | |||
46 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/mbuf.h> | 48 | #include <sys/mbuf.h> | |
@@ -768,27 +768,27 @@ ipsec4_forward(struct mbuf *m, int *dest | @@ -768,27 +768,27 @@ ipsec4_forward(struct mbuf *m, int *dest | |||
768 | * XXX quickhack!!! | 768 | * XXX quickhack!!! | |
769 | */ | 769 | */ | |
770 | struct secpolicy *sp; | 770 | struct secpolicy *sp; | |
771 | size_t ipsechdr; | 771 | size_t ipsechdr; | |
772 | int error; | 772 | int error; | |
773 | 773 | |||
774 | sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_OUTBOUND, IP_FORWARDING, | 774 | sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_OUTBOUND, IP_FORWARDING, | |
775 | &error); | 775 | &error); | |
776 | if (sp == NULL) { | 776 | if (sp == NULL) { | |
777 | return EINVAL; | 777 | return EINVAL; | |
778 | } | 778 | } | |
779 | 779 | |||
780 | /* Count IPsec header size. */ | 780 | /* Count IPsec header size. */ | |
781 | ipsechdr = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL); | 781 | ipsechdr = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL); | |
782 | 782 | |||
783 | /* | 783 | /* | |
784 | * Find the correct route for outer IPv4 header, compute tunnel MTU. | 784 | * Find the correct route for outer IPv4 header, compute tunnel MTU. | |
785 | */ | 785 | */ | |
786 | if (sp->req) { | 786 | if (sp->req) { | |
787 | struct secasvar *sav; | 787 | struct secasvar *sav; | |
788 | 788 | |||
789 | sav = ipsec_lookup_sa(sp->req, m); | 789 | sav = ipsec_lookup_sa(sp->req, m); | |
790 | if (sav != NULL) { | 790 | if (sav != NULL) { | |
791 | struct route *ro; | 791 | struct route *ro; | |
792 | struct rtentry *rt; | 792 | struct rtentry *rt; | |
793 | 793 | |||
794 | ro = &sav->sah->sa_route; | 794 | ro = &sav->sah->sa_route; | |
@@ -1835,83 +1835,53 @@ ipsec_sp_hdrsiz(const struct secpolicy * | @@ -1835,83 +1835,53 @@ ipsec_sp_hdrsiz(const struct secpolicy * | |||
1835 | "IPsec tunnel SA\n", | 1835 | "IPsec tunnel SA\n", | |
1836 | ((const struct sockaddr *)&isr->saidx.dst) | 1836 | ((const struct sockaddr *)&isr->saidx.dst) | |
1837 | ->sa_family); | 1837 | ->sa_family); | |
1838 | break; | 1838 | break; | |
1839 | } | 1839 | } | |
1840 | } | 1840 | } | |
1841 | siz += clen; | 1841 | siz += clen; | |
1842 | } | 1842 | } | |
1843 | 1843 | |||
1844 | return siz; | 1844 | return siz; | |
1845 | } | 1845 | } | |
1846 | 1846 | |||
1847 | size_t | 1847 | size_t | |
1848 | ipsec4_hdrsiz(struct mbuf *m, u_int dir, struct inpcb *inp) | 1848 | ipsec_hdrsiz(struct mbuf *m, u_int dir, void *inp) | |
1849 | { | 1849 | { | |
1850 | struct inpcb_hdr *inph = (struct inpcb_hdr *)inp; | 1850 | struct inpcb_hdr *inph = (struct inpcb_hdr *)inp; | |
1851 | struct secpolicy *sp; | 1851 | struct secpolicy *sp; | |
1852 | int error; | 1852 | int error; | |
1853 | size_t size; | 1853 | size_t size; | |
1854 | 1854 | |||
1855 | KASSERT(m != NULL); | 1855 | KASSERT(m != NULL); | |
1856 | KASSERTMSG(inph == NULL || inph->inph_socket != NULL, | 1856 | KASSERTMSG(inph == NULL || inph->inph_socket != NULL, | |
1857 | "socket w/o inpcb"); | 1857 | "socket w/o inpcb"); | |
1858 | 1858 | |||
1859 | if (inph == NULL) | 1859 | if (inph == NULL) | |
1860 | sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error); | 1860 | sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error); | |
1861 | else | 1861 | else | |
1862 | sp = ipsec_getpolicybysock(m, dir, inph, &error); | 1862 | sp = ipsec_getpolicybysock(m, dir, inph, &error); | |
1863 | 1863 | |||
1864 | if (sp != NULL) { | 1864 | if (sp != NULL) { | |
1865 | size = ipsec_sp_hdrsiz(sp, m); | 1865 | size = ipsec_sp_hdrsiz(sp, m); | |
1866 | KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_DATA, "size:%zu.\n", size); | 1866 | KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_DATA, "size:%zu.\n", size); | |
1867 | KEY_SP_UNREF(&sp); | 1867 | KEY_SP_UNREF(&sp); | |
1868 | } else { | 1868 | } else { | |
1869 | size = 0; | 1869 | size = 0; | |
1870 | } | 1870 | } | |
1871 | 1871 | |||
1872 | return size; | 1872 | return size; | |
1873 | } | 1873 | } | |
1874 | 1874 | |||
1875 | #ifdef INET6 | |||
1876 | size_t | |||
1877 | ipsec6_hdrsiz(struct mbuf *m, u_int dir, struct in6pcb *in6p) | |||
1878 | { | |||
1879 | struct inpcb_hdr *inph = (struct inpcb_hdr *)in6p; | |||
1880 | struct secpolicy *sp; | |||
1881 | int error; | |||
1882 | size_t size; | |||
1883 | ||||
1884 | KASSERT(m != NULL); | |||
1885 | KASSERTMSG(inph == NULL || inph->inph_socket != NULL, | |||
1886 | "socket w/o inpcb"); | |||
1887 | ||||
1888 | if (inph == NULL) | |||
1889 | sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error); | |||
1890 | else | |||
1891 | sp = ipsec_getpolicybysock(m, dir, inph, &error); | |||
1892 | ||||
1893 | if (sp != NULL) { | |||
1894 | size = ipsec_sp_hdrsiz(sp, m); | |||
1895 | KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_DATA, "size:%zu.\n", size); | |||
1896 | KEY_SP_UNREF(&sp); | |||
1897 | } else { | |||
1898 | size = 0; | |||
1899 | } | |||
1900 | ||||
1901 | return size; | |||
1902 | } | |||
1903 | #endif | |||
1904 | ||||
1905 | /* | 1875 | /* | |
1906 | * Check the variable replay window. | 1876 | * Check the variable replay window. | |
1907 | * ipsec_chkreplay() performs replay check before ICV verification. | 1877 | * ipsec_chkreplay() performs replay check before ICV verification. | |
1908 | * ipsec_updatereplay() updates replay bitmap. This must be called after | 1878 | * ipsec_updatereplay() updates replay bitmap. This must be called after | |
1909 | * ICV verification (it also performs replay check, which is usually done | 1879 | * ICV verification (it also performs replay check, which is usually done | |
1910 | * beforehand). | 1880 | * beforehand). | |
1911 | * 0 (zero) is returned if packet disallowed, 1 if packet permitted. | 1881 | * 0 (zero) is returned if packet disallowed, 1 if packet permitted. | |
1912 | * | 1882 | * | |
1913 | * based on RFC 2401. | 1883 | * based on RFC 2401. | |
1914 | */ | 1884 | */ | |
1915 | int | 1885 | int | |
1916 | ipsec_chkreplay(u_int32_t seq, const struct secasvar *sav) | 1886 | ipsec_chkreplay(u_int32_t seq, const struct secasvar *sav) | |
1917 | { | 1887 | { |
--- src/sys/netipsec/ipsec.h 2018/02/21 16:18:52 1.67
+++ src/sys/netipsec/ipsec.h 2018/02/26 08:50:25 1.68
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ipsec.h,v 1.67 2018/02/21 16:18:52 maxv Exp $ */ | 1 | /* $NetBSD: ipsec.h,v 1.68 2018/02/26 08:50:25 maxv Exp $ */ | |
2 | /* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $ */ | 2 | /* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $ */ | |
3 | /* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ | 3 | /* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -294,27 +294,27 @@ u_int ipsec_get_reqlevel(const struct ip | @@ -294,27 +294,27 @@ u_int ipsec_get_reqlevel(const struct ip | |||
294 | int ipsec4_set_policy(struct inpcb *, int, const void *, size_t, kauth_cred_t); | 294 | int ipsec4_set_policy(struct inpcb *, int, const void *, size_t, kauth_cred_t); | |
295 | int ipsec4_get_policy(struct inpcb *, const void *, size_t, struct mbuf **); | 295 | int ipsec4_get_policy(struct inpcb *, const void *, size_t, struct mbuf **); | |
296 | int ipsec4_delete_pcbpolicy(struct inpcb *); | 296 | int ipsec4_delete_pcbpolicy(struct inpcb *); | |
297 | int ipsec4_in_reject(struct mbuf *, struct inpcb *); | 297 | int ipsec4_in_reject(struct mbuf *, struct inpcb *); | |
298 | 298 | |||
299 | struct secasvar *ipsec_lookup_sa(const struct ipsecrequest *, | 299 | struct secasvar *ipsec_lookup_sa(const struct ipsecrequest *, | |
300 | const struct mbuf *); | 300 | const struct mbuf *); | |
301 | 301 | |||
302 | struct secas; | 302 | struct secas; | |
303 | struct tcpcb; | 303 | struct tcpcb; | |
304 | int ipsec_chkreplay(u_int32_t, const struct secasvar *); | 304 | int ipsec_chkreplay(u_int32_t, const struct secasvar *); | |
305 | int ipsec_updatereplay(u_int32_t, const struct secasvar *); | 305 | int ipsec_updatereplay(u_int32_t, const struct secasvar *); | |
306 | 306 | |||
307 | size_t ipsec4_hdrsiz(struct mbuf *, u_int, struct inpcb *); | 307 | size_t ipsec_hdrsiz(struct mbuf *, u_int, void *); | |
308 | size_t ipsec4_hdrsiz_tcp(struct tcpcb *); | 308 | size_t ipsec4_hdrsiz_tcp(struct tcpcb *); | |
309 | 309 | |||
310 | union sockaddr_union; | 310 | union sockaddr_union; | |
311 | const char *ipsec_address(const union sockaddr_union* sa, char *, size_t); | 311 | const char *ipsec_address(const union sockaddr_union* sa, char *, size_t); | |
312 | const char *ipsec_logsastr(const struct secasvar *, char *, size_t); | 312 | const char *ipsec_logsastr(const struct secasvar *, char *, size_t); | |
313 | 313 | |||
314 | void ipsec_dumpmbuf(struct mbuf *); | 314 | void ipsec_dumpmbuf(struct mbuf *); | |
315 | 315 | |||
316 | /* NetBSD protosw ctlin entrypoint */ | 316 | /* NetBSD protosw ctlin entrypoint */ | |
317 | void *esp4_ctlinput(int, const struct sockaddr *, void *); | 317 | void *esp4_ctlinput(int, const struct sockaddr *, void *); | |
318 | void *ah4_ctlinput(int, const struct sockaddr *, void *); | 318 | void *ah4_ctlinput(int, const struct sockaddr *, void *); | |
319 | 319 | |||
320 | void ipsec_output_init(void); | 320 | void ipsec_output_init(void); |
--- src/sys/rump/librump/rumpnet/net_stub.c 2017/08/02 01:28:02 1.27
+++ src/sys/rump/librump/rumpnet/net_stub.c 2018/02/26 08:50:25 1.28
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: net_stub.c,v 1.27 2017/08/02 01:28:02 ozaki-r Exp $ */ | 1 | /* $NetBSD: net_stub.c,v 1.28 2018/02/26 08:50:25 maxv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -16,27 +16,27 @@ | @@ -16,27 +16,27 @@ | |||
16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
25 | * SUCH DAMAGE. | 25 | * SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | #include <sys/cdefs.h> | 28 | #include <sys/cdefs.h> | |
29 | __KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.27 2017/08/02 01:28:02 ozaki-r Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.28 2018/02/26 08:50:25 maxv Exp $"); | |
30 | 30 | |||
31 | #include <sys/mutex.h> | 31 | #include <sys/mutex.h> | |
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/protosw.h> | 33 | #include <sys/protosw.h> | |
34 | #include <sys/socketvar.h> | 34 | #include <sys/socketvar.h> | |
35 | #include <sys/pslist.h> | 35 | #include <sys/pslist.h> | |
36 | #include <sys/psref.h> | 36 | #include <sys/psref.h> | |
37 | 37 | |||
38 | #include <net/if.h> | 38 | #include <net/if.h> | |
39 | #include <net/route.h> | 39 | #include <net/route.h> | |
40 | 40 | |||
41 | #include <netipsec/ipsec.h> | 41 | #include <netipsec/ipsec.h> | |
42 | #include <netipsec/ipsec6.h> | 42 | #include <netipsec/ipsec6.h> | |
@@ -81,39 +81,38 @@ int ipsec_debug; | @@ -81,39 +81,38 @@ int ipsec_debug; | |||
81 | int ipsec_enabled; | 81 | int ipsec_enabled; | |
82 | int ipsec_used; | 82 | int ipsec_used; | |
83 | percpu_t *ipsecstat_percpu; | 83 | percpu_t *ipsecstat_percpu; | |
84 | u_int ipsec_spdgen; | 84 | u_int ipsec_spdgen; | |
85 | 85 | |||
86 | __weak_alias(ah4_ctlinput,rumpnet_stub); | 86 | __weak_alias(ah4_ctlinput,rumpnet_stub); | |
87 | __weak_alias(ah6_ctlinput,rumpnet_stub); | 87 | __weak_alias(ah6_ctlinput,rumpnet_stub); | |
88 | __weak_alias(esp4_ctlinput,rumpnet_stub); | 88 | __weak_alias(esp4_ctlinput,rumpnet_stub); | |
89 | __weak_alias(esp6_ctlinput,rumpnet_stub); | 89 | __weak_alias(esp6_ctlinput,rumpnet_stub); | |
90 | __weak_alias(ipsec4_output,rumpnet_stub); | 90 | __weak_alias(ipsec4_output,rumpnet_stub); | |
91 | __weak_alias(ipsec4_common_input,rumpnet_stub); | 91 | __weak_alias(ipsec4_common_input,rumpnet_stub); | |
92 | __weak_alias(ipsec4_delete_pcbpolicy,rumpnet_stub); | 92 | __weak_alias(ipsec4_delete_pcbpolicy,rumpnet_stub); | |
93 | __weak_alias(ipsec4_forward,rumpnet_stub); | 93 | __weak_alias(ipsec4_forward,rumpnet_stub); | |
94 | __weak_alias(ipsec4_hdrsiz,rumpnet_stub); | |||
95 | __weak_alias(ipsec4_input,rumpnet_stub); | 94 | __weak_alias(ipsec4_input,rumpnet_stub); | |
96 | __weak_alias(ipsec4_in_reject,rumpnet_stub); | 95 | __weak_alias(ipsec4_in_reject,rumpnet_stub); | |
97 | __weak_alias(ipsec4_set_policy,rumpnet_stub); | 96 | __weak_alias(ipsec4_set_policy,rumpnet_stub); | |
98 | __weak_alias(ipsec6_common_input,rumpnet_stub); | 97 | __weak_alias(ipsec6_common_input,rumpnet_stub); | |
99 | __weak_alias(ipsec6_input,rumpnet_stub); | 98 | __weak_alias(ipsec6_input,rumpnet_stub); | |
100 | __weak_alias(ipsec6_check_policy,rumpnet_stub); | 99 | __weak_alias(ipsec6_check_policy,rumpnet_stub); | |
101 | __weak_alias(ipsec6_delete_pcbpolicy,rumpnet_stub); | 100 | __weak_alias(ipsec6_delete_pcbpolicy,rumpnet_stub); | |
102 | __weak_alias(ipsec6_get_policy,rumpnet_stub); | 101 | __weak_alias(ipsec6_get_policy,rumpnet_stub); | |
103 | __weak_alias(ipsec6_in_reject,rumpnet_stub); | 102 | __weak_alias(ipsec6_in_reject,rumpnet_stub); | |
104 | __weak_alias(ipsec6_hdrsiz,rumpnet_stub); | |||
105 | __weak_alias(ipsec6_process_packet,rumpnet_stub); | 103 | __weak_alias(ipsec6_process_packet,rumpnet_stub); | |
106 | __weak_alias(ipsec6_set_policy,rumpnet_stub); | 104 | __weak_alias(ipsec6_set_policy,rumpnet_stub); | |
105 | __weak_alias(ipsec_hdrsiz,rumpnet_stub); | |||
107 | __weak_alias(ipsec_init_policy,rumpnet_stub); | 106 | __weak_alias(ipsec_init_policy,rumpnet_stub); | |
108 | __weak_alias(ipsec_pcbconn,rumpnet_stub); | 107 | __weak_alias(ipsec_pcbconn,rumpnet_stub); | |
109 | __weak_alias(ipsec_pcbdisconn,rumpnet_stub); | 108 | __weak_alias(ipsec_pcbdisconn,rumpnet_stub); | |
110 | __weak_alias(key_sa_routechange,rumpnet_stub); | 109 | __weak_alias(key_sa_routechange,rumpnet_stub); | |
111 | __weak_alias(key_sp_unref,rumpnet_stub); | 110 | __weak_alias(key_sp_unref,rumpnet_stub); | |
112 | 111 | |||
113 | struct ifnet_head ifnet_list; | 112 | struct ifnet_head ifnet_list; | |
114 | struct pslist_head ifnet_pslist; | 113 | struct pslist_head ifnet_pslist; | |
115 | kmutex_t ifnet_mtx; | 114 | kmutex_t ifnet_mtx; | |
116 | 115 | |||
117 | int | 116 | int | |
118 | compat_ifconf(u_long cmd, void *data) | 117 | compat_ifconf(u_long cmd, void *data) | |
119 | { | 118 | { |