From owner-svn-src-projects@freebsd.org Thu Dec 22 13:53:40 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 212C5C8A5E0 for ; Thu, 22 Dec 2016 13:53:40 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB2C8EF; Thu, 22 Dec 2016 13:53:39 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBMDrdxc064687; Thu, 22 Dec 2016 13:53:39 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBMDrcMD064686; Thu, 22 Dec 2016 13:53:38 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201612221353.uBMDrcMD064686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 22 Dec 2016 13:53:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r310397 - projects/ipsec/sys/netinet X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2016 13:53:40 -0000 Author: ae Date: Thu Dec 22 13:53:38 2016 New Revision: 310397 URL: https://svnweb.freebsd.org/changeset/base/310397 Log: Convert ip_output.c to use IPsec methods. Modified: projects/ipsec/sys/netinet/ip_output.c Modified: projects/ipsec/sys/netinet/ip_output.c ============================================================================== --- projects/ipsec/sys/netinet/ip_output.c Thu Dec 22 13:52:30 2016 (r310396) +++ projects/ipsec/sys/netinet/ip_output.c Thu Dec 22 13:53:38 2016 (r310397) @@ -83,10 +83,7 @@ __FBSDID("$FreeBSD$"); #include #endif -#ifdef IPSEC -#include -#include -#endif /* IPSEC*/ +#include #include @@ -227,7 +224,7 @@ ip_output(struct mbuf *m, struct mbuf *o struct rtentry *rte; /* cache for ro->ro_rt */ uint32_t fibnum; int have_ia_ref; -#ifdef IPSEC +#if defined(IPSEC) || defined(IPSEC_SUPPORT) int no_route_but_check_spd = 0; #endif M_ASSERTPKTHDR(m); @@ -383,7 +380,7 @@ again: (rte->rt_flags & RTF_UP) == 0 || rte->rt_ifp == NULL || !RT_LINK_IS_UP(rte->rt_ifp)) { -#ifdef IPSEC +#if defined(IPSEC) || defined(IPSEC_SUPPORT) /* * There is no route for this packet, but it is * possible that a matching SPD entry exists. @@ -555,9 +552,14 @@ again: } sendit: -#ifdef IPSEC - if (IPSEC_OUTPUT(ipv4, m, inp, &error) != 0) - goto done; +#if defined(IPSEC) || defined(IPSEC_SUPPORT) + if (IPSEC_ENABLED(ipv4)) { + if ((error = IPSEC_OUTPUT(ipv4, m, inp)) != 0) { + if (error == EINPROGRESS) + error = 0; + goto done; + } + } /* * Check if there was a route for this packet; return error if not. */ @@ -1181,10 +1183,13 @@ ip_ctloutput(struct socket *so, struct s INP_WUNLOCK(inp); break; -#ifdef IPSEC +#if defined(IPSEC) || defined(IPSEC_SUPPORT) case IP_IPSEC_POLICY: - error = ip_ipsec_pcbctl(inp, sopt); - break; + if (IPSEC_ENABLED(ipv4)) { + error = IPSEC_PCBCTL(ipv4, inp, sopt); + break; + } + /* FALLTHROUGH */ #endif /* IPSEC */ default: @@ -1327,10 +1332,13 @@ ip_ctloutput(struct socket *so, struct s error = inp_getmoptions(inp, sopt); break; -#ifdef IPSEC +#if defined(IPSEC) || defined(IPSEC_SUPPORT) case IP_IPSEC_POLICY: - error = ip_ipsec_pcbctl(inp, sopt); - break; + if (IPSEC_ENABLED(ipv4)) { + error = IPSEC_PCBCTL(ipv4, inp, sopt); + break; + } + /* FALLTHROUGH */ #endif /* IPSEC */ default: