From owner-svn-src-projects@freebsd.org Thu Dec 15 17:41:31 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 8879BC8139D for ; Thu, 15 Dec 2016 17:41:31 +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 635E9B95; Thu, 15 Dec 2016 17:41:31 +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 uBFHfUQR018531; Thu, 15 Dec 2016 17:41:30 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBFHfU51018528; Thu, 15 Dec 2016 17:41:30 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201612151741.uBFHfU51018528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 15 Dec 2016 17:41:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r310125 - projects/ipsec/sys/netipsec 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, 15 Dec 2016 17:41:31 -0000 Author: ae Date: Thu Dec 15 17:41:30 2016 New Revision: 310125 URL: https://svnweb.freebsd.org/changeset/base/310125 Log: Move xform_register() and xform_init() into key.c Modified: projects/ipsec/sys/netipsec/ipsec.c projects/ipsec/sys/netipsec/key.c projects/ipsec/sys/netipsec/xform.h Modified: projects/ipsec/sys/netipsec/ipsec.c ============================================================================== --- projects/ipsec/sys/netipsec/ipsec.c Thu Dec 15 17:36:54 2016 (r310124) +++ projects/ipsec/sys/netipsec/ipsec.c Thu Dec 15 17:41:30 2016 (r310125) @@ -1504,35 +1504,3 @@ def_policy_init(const void *unused __unu } VNET_SYSINIT(def_policy_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, def_policy_init, NULL); - - -/* XXX This stuff doesn't belong here... */ - -static struct xformsw* xforms = NULL; - -/* - * Register a transform; typically at system startup. - */ -void -xform_register(struct xformsw* xsp) -{ - - xsp->xf_next = xforms; - xforms = xsp; -} - -/* - * Initialize transform support in an sav. - */ -int -xform_init(struct secasvar *sav, int xftype) -{ - struct xformsw *xsp; - - if (sav->tdb_xform != NULL) /* Previously initialized. */ - return (0); - for (xsp = xforms; xsp; xsp = xsp->xf_next) - if (xsp->xf_type == xftype) - return ((*xsp->xf_init)(sav, xsp)); - return (EINVAL); -} Modified: projects/ipsec/sys/netipsec/key.c ============================================================================== --- projects/ipsec/sys/netipsec/key.c Thu Dec 15 17:36:54 2016 (r310124) +++ projects/ipsec/sys/netipsec/key.c Thu Dec 15 17:41:30 2016 (r310125) @@ -448,6 +448,8 @@ MALLOC_DEFINE(M_IPSEC_SAR, "ipsec-reg", static VNET_DEFINE(uma_zone_t, key_lft_zone); #define V_key_lft_zone VNET(key_lft_zone) +static struct xformsw* xforms = NULL; + /* * set parameters into secpolicyindex buffer. * Must allocate secpolicyindex buffer passed to this function. @@ -608,9 +610,9 @@ static int key_promisc(struct socket *, static int key_senderror(struct socket *, struct mbuf *, int); static int key_validate_ext(const struct sadb_ext *, int); static int key_align(struct mbuf *, struct sadb_msghdr *); -static struct mbuf *key_setlifetime(struct seclifetime *src, - u_int16_t exttype); -static struct mbuf *key_setkey(struct seckey *src, u_int16_t exttype); +static struct mbuf *key_setlifetime(struct seclifetime *, uint16_t); +static struct mbuf *key_setkey(struct seckey *, uint16_t); +static int xform_init(struct secasvar *, int); #define DBG_IPSEC_INITREF(t, p) do { \ refcount_init(&(p)->refcnt, 1); \ @@ -7805,7 +7807,7 @@ key_sa_recordxfer(struct secasvar *sav, */ static struct mbuf * -key_setkey(struct seckey *src, u_int16_t exttype) +key_setkey(struct seckey *src, uint16_t exttype) { struct mbuf *m; struct sadb_key *p; @@ -7845,7 +7847,7 @@ key_setkey(struct seckey *src, u_int16_t */ static struct mbuf * -key_setlifetime(struct seclifetime *src, u_int16_t exttype) +key_setlifetime(struct seclifetime *src, uint16_t exttype) { struct mbuf *m = NULL; struct sadb_lifetime *p; @@ -7872,3 +7874,30 @@ key_setlifetime(struct seclifetime *src, return m; } + +/* + * Register a transform; typically at system startup. + */ +void +xform_register(struct xformsw* xsp) +{ + + xsp->xf_next = xforms; + xforms = xsp; +} + +/* + * Initialize transform support in an sav. + */ +static int +xform_init(struct secasvar *sav, int xftype) +{ + struct xformsw *xsp; + + if (sav->tdb_xform != NULL) /* Previously initialized. */ + return (0); + for (xsp = xforms; xsp; xsp = xsp->xf_next) + if (xsp->xf_type == xftype) + return ((*xsp->xf_init)(sav, xsp)); + return (EINVAL); +} Modified: projects/ipsec/sys/netipsec/xform.h ============================================================================== --- projects/ipsec/sys/netipsec/xform.h Thu Dec 15 17:36:54 2016 (r310124) +++ projects/ipsec/sys/netipsec/xform.h Thu Dec 15 17:41:30 2016 (r310125) @@ -99,7 +99,6 @@ struct xformsw { #ifdef _KERNEL extern void xform_register(struct xformsw*); -extern int xform_init(struct secasvar *sav, int xftype); extern int xform_ah_authsize(struct auth_hash *esph); struct cryptoini;