From owner-svn-src-head@freebsd.org Sun Apr 24 17:09:52 2016 Return-Path: Delivered-To: svn-src-head@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 EC6CEB1BF00; Sun, 24 Apr 2016 17:09:52 +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 BB8331224; Sun, 24 Apr 2016 17:09:52 +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 u3OH9peG087193; Sun, 24 Apr 2016 17:09:51 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3OH9pj4087192; Sun, 24 Apr 2016 17:09:51 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201604241709.u3OH9pj4087192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sun, 24 Apr 2016 17:09:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298549 - head/sys/netipsec X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Apr 2016 17:09:53 -0000 Author: ae Date: Sun Apr 24 17:09:51 2016 New Revision: 298549 URL: https://svnweb.freebsd.org/changeset/base/298549 Log: Fix build for NOINET and NOINET6 kernels. Use own protosw structures for both address families. Check proto in encapcheck function and use -1 as proto argument in encap_attach_func(), both address families can have IPPROTO_IPV4 and IPPROTO_IPV6 protocols. Reported by: bz Modified: head/sys/netipsec/xform_ipcomp.c Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Sun Apr 24 16:41:54 2016 (r298548) +++ head/sys/netipsec/xform_ipcomp.c Sun Apr 24 17:09:51 2016 (r298549) @@ -50,7 +50,6 @@ #include #include -#include #include #include @@ -58,6 +57,7 @@ #ifdef INET6 #include +#include #include #endif @@ -65,7 +65,6 @@ #include #include -#include #include #include @@ -101,7 +100,6 @@ ipcomp_algorithm_lookup(int alg) return NULL; } -#if defined(INET) || defined(INET6) /* * RFC 3173 p 2.2. Non-Expansion Policy: * If the total size of a compressed payload and the IPComp header, as @@ -157,19 +155,6 @@ ipcomp_nonexp_input(struct mbuf **mp, in return (IPPROTO_DONE); } -extern struct domain inetdomain; -static struct protosw ipcomp_protosw = { - .pr_type = SOCK_RAW, - .pr_domain = &inetdomain, - .pr_protocol = 0 /* IPPROTO_IPV[46] */, - .pr_flags = PR_ATOMIC | PR_ADDR | PR_LASTHDR, - .pr_input = ipcomp_nonexp_input, - .pr_output = rip_output, - .pr_ctloutput = rip_ctloutput, - .pr_usrreqs = &rip_usrreqs -}; -#endif /* INET || INET6 */ - /* * ipcomp_init() is called when an CPI is being set up. */ @@ -702,6 +687,18 @@ static struct xformsw ipcomp_xformsw = { #ifdef INET static const struct encaptab *ipe4_cookie = NULL; +extern struct domain inetdomain; +static struct protosw ipcomp4_protosw = { + .pr_type = SOCK_RAW, + .pr_domain = &inetdomain, + .pr_protocol = 0 /* IPPROTO_IPV[46] */, + .pr_flags = PR_ATOMIC | PR_ADDR | PR_LASTHDR, + .pr_input = ipcomp_nonexp_input, + .pr_output = rip_output, + .pr_ctloutput = rip_ctloutput, + .pr_usrreqs = &rip_usrreqs +}; + static int ipcomp4_nonexp_encapcheck(const struct mbuf *m, int off, int proto, void *arg __unused) @@ -711,6 +708,8 @@ ipcomp4_nonexp_encapcheck(const struct m if (V_ipcomp_enable == 0) return (0); + if (proto != IPPROTO_IPV4 && proto != IPPROTO_IPV6) + return (0); bzero(&src, sizeof(src)); bzero(&dst, sizeof(dst)); src.sa.sa_family = dst.sa.sa_family = AF_INET; @@ -723,6 +722,18 @@ ipcomp4_nonexp_encapcheck(const struct m #endif #ifdef INET6 static const struct encaptab *ipe6_cookie = NULL; +extern struct domain inet6domain; +static struct protosw ipcomp6_protosw = { + .pr_type = SOCK_RAW, + .pr_domain = &inet6domain, + .pr_protocol = 0 /* IPPROTO_IPV[46] */, + .pr_flags = PR_ATOMIC | PR_ADDR | PR_LASTHDR, + .pr_input = ipcomp_nonexp_input, + .pr_output = rip6_output, + .pr_ctloutput = rip6_ctloutput, + .pr_usrreqs = &rip6_usrreqs +}; + static int ipcomp6_nonexp_encapcheck(const struct mbuf *m, int off, int proto, void *arg __unused) @@ -732,6 +743,8 @@ ipcomp6_nonexp_encapcheck(const struct m if (V_ipcomp_enable == 0) return (0); + if (proto != IPPROTO_IPV4 && proto != IPPROTO_IPV6) + return (0); bzero(&src, sizeof(src)); bzero(&dst, sizeof(dst)); src.sa.sa_family = dst.sa.sa_family = AF_INET; @@ -760,12 +773,12 @@ ipcomp_attach(void) { #ifdef INET - ipe4_cookie = encap_attach_func(AF_INET, IPPROTO_IPV4, - ipcomp4_nonexp_encapcheck, &ipcomp_protosw, NULL); + ipe4_cookie = encap_attach_func(AF_INET, -1, + ipcomp4_nonexp_encapcheck, &ipcomp4_protosw, NULL); #endif #ifdef INET6 - ipe6_cookie = encap_attach_func(AF_INET6, IPPROTO_IPV6, - ipcomp6_nonexp_encapcheck, &ipcomp_protosw, NULL); + ipe6_cookie = encap_attach_func(AF_INET6, -1, + ipcomp6_nonexp_encapcheck, &ipcomp6_protosw, NULL); #endif xform_register(&ipcomp_xformsw); }