From owner-svn-src-head@freebsd.org Fri Jul 13 23:46:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B309102B268; Fri, 13 Jul 2018 23:46:10 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F1BE7DCC9; Fri, 13 Jul 2018 23:46:10 +0000 (UTC) (envelope-from cem@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 10D671704A; Fri, 13 Jul 2018 23:46:10 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6DNk945008195; Fri, 13 Jul 2018 23:46:09 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6DNk7CL008183; Fri, 13 Jul 2018 23:46:07 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201807132346.w6DNk7CL008183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Fri, 13 Jul 2018 23:46:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336269 - in head/sys: netipsec opencrypto X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: netipsec opencrypto X-SVN-Commit-Revision: 336269 X-SVN-Commit-Repository: base 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.27 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: Fri, 13 Jul 2018 23:46:10 -0000 Author: cem Date: Fri Jul 13 23:46:07 2018 New Revision: 336269 URL: https://svnweb.freebsd.org/changeset/base/336269 Log: OCF: Add a typedef for session identifiers No functional change. This should ease the transition from an integer session identifier model to an opaque pointer model. Added: head/sys/opencrypto/_cryptodev.h (contents, props changed) Modified: head/sys/netipsec/ipsec.c head/sys/netipsec/ipsec.h head/sys/netipsec/keydb.h head/sys/netipsec/xform.h head/sys/netipsec/xform_ah.c head/sys/netipsec/xform_esp.c head/sys/netipsec/xform_ipcomp.c head/sys/opencrypto/crypto.c head/sys/opencrypto/cryptodev.c head/sys/opencrypto/cryptodev.h head/sys/opencrypto/cryptodev_if.m Modified: head/sys/netipsec/ipsec.c ============================================================================== --- head/sys/netipsec/ipsec.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/ipsec.c Fri Jul 13 23:46:07 2018 (r336269) @@ -1322,9 +1322,10 @@ ok: } int -ipsec_updateid(struct secasvar *sav, uint64_t *new, uint64_t *old) +ipsec_updateid(struct secasvar *sav, crypto_session_t *new, + crypto_session_t *old) { - uint64_t tmp; + crypto_session_t tmp; /* * tdb_cryptoid is initialized by xform_init(). Modified: head/sys/netipsec/ipsec.h ============================================================================== --- head/sys/netipsec/ipsec.h Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/ipsec.h Fri Jul 13 23:46:07 2018 (r336269) @@ -332,7 +332,7 @@ int udp_ipsec_pcbctl(struct inpcb *, struct sockopt *) int ipsec_chkreplay(uint32_t, struct secasvar *); int ipsec_updatereplay(uint32_t, struct secasvar *); -int ipsec_updateid(struct secasvar *, uint64_t *, uint64_t *); +int ipsec_updateid(struct secasvar *, crypto_session_t *, crypto_session_t *); int ipsec_initialized(void); void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int); Modified: head/sys/netipsec/keydb.h ============================================================================== --- head/sys/netipsec/keydb.h Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/keydb.h Fri Jul 13 23:46:07 2018 (r336269) @@ -41,6 +41,7 @@ #include #include +#include #ifndef _SOCKADDR_UNION_DEFINED #define _SOCKADDR_UNION_DEFINED @@ -162,7 +163,7 @@ struct secasvar { const struct enc_xform *tdb_encalgxform;/* encoding algorithm */ const struct auth_hash *tdb_authalgxform;/* authentication algorithm */ const struct comp_algo *tdb_compalgxform;/* compression algorithm */ - uint64_t tdb_cryptoid; /* crypto session id */ + crypto_session_t tdb_cryptoid; /* crypto session */ uint8_t alg_auth; /* Authentication Algorithm Identifier*/ uint8_t alg_enc; /* Cipher Algorithm Identifier */ Modified: head/sys/netipsec/xform.h ============================================================================== --- head/sys/netipsec/xform.h Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/xform.h Fri Jul 13 23:46:07 2018 (r336269) @@ -71,7 +71,7 @@ struct xform_history { struct xform_data { struct secpolicy *sp; /* security policy */ struct secasvar *sav; /* related SA */ - uint64_t cryptoid; /* used crypto session id */ + crypto_session_t cryptoid; /* used crypto session */ u_int idx; /* IPsec request index */ int protoff; /* current protocol offset */ int skip; /* data offset */ Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/xform_ah.c Fri Jul 13 23:46:07 2018 (r336269) @@ -544,7 +544,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski struct cryptop *crp; struct xform_data *xd; struct newah *ah; - uint64_t cryptoid; + crypto_session_t cryptoid; int hl, rplen, authsize, ahsize, error; IPSEC_ASSERT(sav != NULL, ("null SA")); @@ -699,7 +699,7 @@ ah_input_cb(struct cryptop *crp) struct secasvar *sav; struct secasindex *saidx; caddr_t ptr; - uint64_t cryptoid; + crypto_session_t cryptoid; int authsize, rplen, ahsize, error, skip, protoff; uint8_t nxt; @@ -849,7 +849,7 @@ ah_output(struct mbuf *m, struct secpolicy *sp, struct struct mbuf *mi; struct cryptop *crp; struct newah *ah; - uint64_t cryptoid; + crypto_session_t cryptoid; uint16_t iplen; int error, rplen, authsize, ahsize, maxpacketsize, roff; uint8_t prot; @@ -1082,7 +1082,7 @@ ah_output_cb(struct cryptop *crp) struct secpolicy *sp; struct secasvar *sav; struct mbuf *m; - uint64_t cryptoid; + crypto_session_t cryptoid; caddr_t ptr; u_int idx; int skip, error; Modified: head/sys/netipsec/xform_esp.c ============================================================================== --- head/sys/netipsec/xform_esp.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/xform_esp.c Fri Jul 13 23:46:07 2018 (r336269) @@ -271,7 +271,7 @@ esp_input(struct mbuf *m, struct secasvar *sav, int sk struct cryptop *crp; struct newesp *esp; uint8_t *ivp; - uint64_t cryptoid; + crypto_session_t cryptoid; int alen, error, hlen, plen; IPSEC_ASSERT(sav != NULL, ("null SA")); @@ -448,7 +448,7 @@ esp_input_cb(struct cryptop *crp) struct secasvar *sav; struct secasindex *saidx; caddr_t ptr; - uint64_t cryptoid; + crypto_session_t cryptoid; int hlen, skip, protoff, error, alen; crd = crp->crp_desc; @@ -637,7 +637,8 @@ esp_output(struct mbuf *m, struct secpolicy *sp, struc struct secasindex *saidx; unsigned char *pad; uint8_t *ivp; - uint64_t cntr, cryptoid; + uint64_t cntr; + crypto_session_t cryptoid; int hlen, rlen, padding, blks, alen, i, roff; int error, maxpacketsize; uint8_t prot; @@ -883,7 +884,7 @@ esp_output_cb(struct cryptop *crp) struct secpolicy *sp; struct secasvar *sav; struct mbuf *m; - uint64_t cryptoid; + crypto_session_t cryptoid; u_int idx; int error; Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/netipsec/xform_ipcomp.c Fri Jul 13 23:46:07 2018 (r336269) @@ -280,7 +280,7 @@ ipcomp_input_cb(struct cryptop *crp) struct secasvar *sav; struct secasindex *saidx; caddr_t addr; - uint64_t cryptoid; + crypto_session_t cryptoid; int hlen = IPCOMP_HLENGTH, error, clen; int skip, protoff; uint8_t nproto; @@ -531,7 +531,7 @@ ipcomp_output_cb(struct cryptop *crp) struct secpolicy *sp; struct secasvar *sav; struct mbuf *m; - uint64_t cryptoid; + crypto_session_t cryptoid; u_int idx; int error, skip, protoff; Added: head/sys/opencrypto/_cryptodev.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/opencrypto/_cryptodev.h Fri Jul 13 23:46:07 2018 (r336269) @@ -0,0 +1,8 @@ +/* + * This trivial work is released to the public domain, or licensed under the + * terms of the CC0, at your option. + * $FreeBSD$ + */ +#pragma once + +typedef __uint64_t crypto_session_t; Modified: head/sys/opencrypto/crypto.c ============================================================================== --- head/sys/opencrypto/crypto.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/opencrypto/crypto.c Fri Jul 13 23:46:07 2018 (r336269) @@ -488,7 +488,7 @@ again: * must be capable of the requested crypto algorithms. */ int -crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int crid) +crypto_newsession(crypto_session_t *sid, struct cryptoini *cri, int crid) { struct cryptocap *cap; u_int32_t hid, lid; @@ -548,7 +548,7 @@ crypto_remove(struct cryptocap *cap) * driver). */ int -crypto_freesession(u_int64_t sid) +crypto_freesession(crypto_session_t sid) { struct cryptocap *cap; u_int32_t hid; @@ -1162,7 +1162,7 @@ crypto_invoke(struct cryptocap *cap, struct cryptop *c #endif if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) { struct cryptodesc *crd; - u_int64_t nid; + crypto_session_t nid; /* * Driver has unregistered; migrate the session and return Modified: head/sys/opencrypto/cryptodev.c ============================================================================== --- head/sys/opencrypto/cryptodev.c Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/opencrypto/cryptodev.c Fri Jul 13 23:46:07 2018 (r336269) @@ -265,7 +265,7 @@ crypt_kop_to_32(const struct crypt_kop *from, struct c struct csession { TAILQ_ENTRY(csession) next; - u_int64_t sid; + crypto_session_t sid; u_int32_t ses; struct mtx lock; /* for op submission */ @@ -320,7 +320,7 @@ static struct fileops cryptofops = { static struct csession *csefind(struct fcrypt *, u_int); static int csedelete(struct fcrypt *, struct csession *); static struct csession *cseadd(struct fcrypt *, struct csession *); -static struct csession *csecreate(struct fcrypt *, u_int64_t, caddr_t, +static struct csession *csecreate(struct fcrypt *, crypto_session_t, caddr_t, u_int64_t, caddr_t, u_int64_t, u_int32_t, u_int32_t, struct enc_xform *, struct auth_hash *); static int csefree(struct csession *); @@ -378,7 +378,7 @@ cryptof_ioctl( struct enc_xform *txform = NULL; struct auth_hash *thash = NULL; struct crypt_kop *kop; - u_int64_t sid; + crypto_session_t sid; u_int32_t ses; int error = 0, crid; #ifdef COMPAT_FREEBSD32 @@ -1350,7 +1350,7 @@ cseadd(struct fcrypt *fcr, struct csession *cse) } struct csession * -csecreate(struct fcrypt *fcr, u_int64_t sid, caddr_t key, u_int64_t keylen, +csecreate(struct fcrypt *fcr, crypto_session_t sid, caddr_t key, u_int64_t keylen, caddr_t mackey, u_int64_t mackeylen, u_int32_t cipher, u_int32_t mac, struct enc_xform *txform, struct auth_hash *thash) { Modified: head/sys/opencrypto/cryptodev.h ============================================================================== --- head/sys/opencrypto/cryptodev.h Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/opencrypto/cryptodev.h Fri Jul 13 23:46:07 2018 (r336269) @@ -65,6 +65,10 @@ #include #include +#ifdef _KERNEL +#include +#endif + /* Some initial values */ #define CRYPTO_DRIVERS_INITIAL 4 #define CRYPTO_SW_SESSIONS 32 @@ -408,7 +412,7 @@ struct cryptop { struct task crp_task; - u_int64_t crp_sid; /* Session ID */ + crypto_session_t crp_sid; /* Session ID */ int crp_ilen; /* Input data total length */ int crp_olen; /* Result total length */ @@ -502,8 +506,8 @@ struct cryptkop { MALLOC_DECLARE(M_CRYPTO_DATA); -extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard); -extern int crypto_freesession(u_int64_t sid); +extern int crypto_newsession(crypto_session_t *sid, struct cryptoini *cri, int hard); +extern int crypto_freesession(crypto_session_t sid); #define CRYPTOCAP_F_HARDWARE CRYPTO_FLAG_HARDWARE #define CRYPTOCAP_F_SOFTWARE CRYPTO_FLAG_SOFTWARE #define CRYPTOCAP_F_SYNC 0x04000000 /* operates synchronously */ Modified: head/sys/opencrypto/cryptodev_if.m ============================================================================== --- head/sys/opencrypto/cryptodev_if.m Fri Jul 13 22:49:48 2018 (r336268) +++ head/sys/opencrypto/cryptodev_if.m Fri Jul 13 23:46:07 2018 (r336269) @@ -39,7 +39,7 @@ METHOD int newsession { METHOD int freesession { device_t dev; - uint64_t sid; + crypto_session_t sid; }; METHOD int process {