Does Openvpn really support cryptodev hardware accelerators
Hi,
I am working on try use the cryptodev hardware accelerator in Openvpn, i know this question is belong to user list, but i got confused for the issue, so, i think maybe need developer to help :)
I have two boards, one is Freescale LS1021a ARM cpu, another one is INTEL E3815 cpu, both of them i can enable the cryptodev hardware accelerator, and tested them in openssl, it working good when enabled the cryptodev, i can got about 72 times performance improved with command "openssl speed -evp aes-128-cbc", here is a INTEL cpu test result----------with cryptodev support:[email protected]...:/etc/openvpn# /usr/local/ssl/bin/openssl speed -evp aes-128-cbcDoing aes-128-cbc for 3s on 16 size blocks: 1324358 aes-128-cbc's in 0.47sDoing aes-128-cbc for 3s on 64 size blocks: 986320 aes-128-cbc's in 0.33sDoing aes-128-cbc for 3s on 256 size blocks: 487522 aes-128-cbc's in 0.19sDoing aes-128-cbc for 3s on 1024 size blocks: 157636 aes-128-cbc's in 0.05sDoing aes-128-cbc for 3s on 8192 size blocks: 22318 aes-128-cbc's in 0.01sOpenSSL 1.0.2 22 Jan 2015built on: reproducible build, date unspecifiedoptions:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx)compiler: gcc -I. -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASMThe 'numbers' are in 1000s of bytes per second processed.type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytesaes-128-cbc 45084.53k 191286.30k 656871.75k 3228385.28k [email protected]...:/etc/openvpn#----------without cryptodev support:[email protected]...:/etc/openvpn# /usr/local/ssl/bin/openssl speed -evp aes-128-cbcDoing aes-128-cbc for 3s on 16 size blocks: 29624370 aes-128-cbc's in 2.99sDoing aes-128-cbc for 3s on 64 size blocks: 10070739 aes-128-cbc's in 3.01sDoing aes-128-cbc for 3s on 256 size blocks: 2846673 aes-128-cbc's in 3.00sDoing aes-128-cbc for 3s on 1024 size blocks: 735685 aes-128-cbc's in 3.01sDoing aes-128-cbc for 3s on 8192 size blocks: 92783 aes-128-cbc's in 3.00sOpenSSL 1.0.2 22 Jan 2015built on: reproducible build, date unspecifiedoptions:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx)compiler: gcc -I. -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASMThe 'numbers' are in 1000s of bytes per second processed.type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytesaes-128-cbc 158525.06k 214128.67k 242916.10k 250279.55k 253359.45k----------
it was got big improved with cryptodev hardware accelerator you can see from above shows
but when i configured and compiled Openvpn with HAVE_OPENSSL_ENGINE supported, and i can make sure Openvpn can working with cryptodev [email protected]...:/etc/openvpn# /opt/openvpn/sbin/openvpn --show-enginesOpenSSL Crypto Engines
BSD cryptodev engine [cryptodev]Intel RDRAND engine [rdrand]Dynamic engine loading support [dynamic]IBM 4758 CCA hardware engine support [4758cca]Aep hardware engine support [aep]Atalla hardware engine support [atalla]CryptoSwift hardware engine support [cswift]CHIL hardware engine support [chil]Nuron hardware engine support [nuron]SureWare hardware engine support [sureware]UBSEC hardware engine support [ubsec]Reference implementation of GOST engine [gost]-------
without [email protected]...:/etc/openvpn# iperf -s------------------------------------------------------------Server listening on TCP port 5001TCP window size: 85.3 KByte (default)------------------------------------------------------------[ 4] local 192.168.1.13 port 5001 connected with 192.168.1.110 port 52444[ ID] Interval Transfer Bandwidth[ 4] 0.0-10.1 sec 82.1 MBytes 68.4 Mbits/sec-------with cryptodev-------[ 5] local 192.168.1.13 port 5001 connected with 192.168.1.110 port 52446[ 5] 0.0-10.1 sec 43.1 MBytes 35.7 Mbits/sec-------
the iperf shows throughput even cut down from 68Mbis/sec to 35.7Mbits/sec!!!
i can make sure the cryptodev engine has been loaded in openvpn, and used cipher is aes-128-cbc in openvpn configuration file------Fri Jul 24 16:35:21 2015 Initializing OpenSSL support for engine 'cryptodev'Fri Jul 24 16:35:21 2015 Diffie-Hellman initialized with 2048 bit keyFri Jul 24 16:35:21 2015 Control Channel Authentication: using 'ta.key' as a OpenVPN static key fileFri Jul 24 16:35:21 2015 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authenticationFri Jul 24 16:35:21 2015 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authenticationFri Jul 24 16:35:21 2015 Socket Buffers: R=[212992->131072] S=[212992->131072]Fri Jul 24 16:35:21 2015 TUN/TAP device tap0 openedFri Jul 24 16:35:21 2015 TUN/TAP TX queue length set to 100Fri Jul 24 16:35:21 2015 /etc/openvpn/up.sh br0 tap0 1500 1589 initFri Jul 24 16:35:21 2015 GID set to nogroupFri Jul 24 16:35:21 2015 UID set to nobodyFri Jul 24 16:35:21 2015 UDPv4 link local (bound): [undef]Fri Jul 24 16:35:21 2015 UDPv4 link remote: [undef]Fri Jul 24 16:35:21 2015 MULTI: multi_init called, r=256 v=256Fri Jul 24 16:35:21 2015 IFCONFIG POOL: base=192.168.1.110 size=9, ipv6=0Fri Jul 24 16:35:21 2015 ifconfig_pool_read(), in='client,192.168.1.110', TODO: IPv6Fri Jul 24 16:35:21 2015 succeeded -> ifconfig_pool_set()Fri Jul 24 16:35:21 2015 IFCONFIG POOL LISTFri Jul 24 16:35:21 2015 client,192.168.1.110Fri Jul 24 16:35:21 2015 Initialization Sequence Completed----Fri Jul 24 16:35:32 2015 192.168.2.187:48539 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit keyFri Jul 24 16:35:32 2015 192.168.2.187:48539 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authenticationFri Jul 24 16:35:32 2015 192.168.2.187:48539 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit keyFri Jul 24 16:35:32 2015 192.168.2.187:48539 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authenticationFri Jul 24 16:35:32 2015 192.168.2.187:48539 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSAFri Jul 24 16:35:32 2015 192.168.2.187:48539 [client] Peer Connection Initiated with [AF_INET]192.168.2.187:48539Fri Jul 24 16:35:32 2015 client/192.168.2.187:48539 MULTI_sva: pool returned IPv4=192.168.1.110, IPv6=(Not enabled)Fri Jul 24 16:35:34 2015 client/192.168.2.187:48539 PUSH: Received control message: 'PUSH_REQUEST'Fri Jul 24 16:35:34 2015 client/192.168.2.187:48539 send_push_reply(): safe_cap=940Fri Jul 24 16:35:34 2015 client/192.168.2.187:48539 SENT CONTROL [client]: 'PUSH_REPLY,route-gateway 192.168.1.13,ping 10,ping-restart 120,ifconfig 192.168.1.110 255.255.255.0' (status=1)Fri Jul 24 16:35:34 2015 client/192.168.2.187:48539 MULTI: Learn: da:78:09:89:40:24 -> client/192.168.2.187:48539----
any ideas, and does Openvpn really support cryptodev hardware accelerator? thank you!
Yuqian
Hi,
if openssl uses cryptodev, so will openvpn - we don't do our own crypto, just call the openvpn functions to do so.
(And on FreeBSD, this is the particular reason why we had so much trouble recently, as our way to do --daemon wasn't compatible with cryptodev...)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 60 lines · li yuqian
Hi,
I am working on try use the cryptodev hardware accelerator in Openvpn, i know this question is belong to user list, but i got confused for the issue, so, i think maybe need developer to help :)
I have two boards, one is Freescale LS1021a ARM cpu, another one is INTEL E3815 cpu, both of them i can enable the cryptodev hardware accelerator, and tested them in openssl, it working good when enabled the cryptodev, i can got about 72 times performance improved with command "openssl speed -evp aes-128-cbc", here is a INTEL cpu test result
----------
with cryptodev support:
----------[email protected]...:/etc/openvpn# /usr/local/ssl/bin/openssl speed -evp aes-128-cbc Doing aes-128-cbc for 3s on 16 size blocks: 1324358 aes-128-cbc's in 0.47s Doing aes-128-cbc for 3s on 64 size blocks: 986320 aes-128-cbc's in 0.33s Doing aes-128-cbc for 3s on 256 size blocks: 487522 aes-128-cbc's in 0.19s Doing aes-128-cbc for 3s on 1024 size blocks: 157636 aes-128-cbc's in 0.05s Doing aes-128-cbc for 3s on 8192 size blocks: 22318 aes-128-cbc's in 0.01s OpenSSL 1.0.2 22 Jan 2015 built on: reproducible build, date unspecified options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx) compiler: gcc -I. -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT(quoted diff) +0
-6-DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASMThe 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes aes-128-cbc 45084.53k 191286.30k 656871.75k 3228385.28k 18282905.60k[email protected]...:/etc/openvpn#
----------
without cryptodev support:
----------[email protected]...:/etc/openvpn# /usr/local/ssl/bin/openssl speed -evp aes-128-cbc Doing aes-128-cbc for 3s on 16 size blocks: 29624370 aes-128-cbc's in 2.99s Doing aes-128-cbc for 3s on 64 size blocks: 10070739 aes-128-cbc's in 3.01s Doing aes-128-cbc for 3s on 256 size blocks: 2846673 aes-128-cbc's in 3.00s Doing aes-128-cbc for 3s on 1024 size blocks: 735685 aes-128-cbc's in 3.01s Doing aes-128-cbc for 3s on 8192 size blocks: 92783 aes-128-cbc's in 3.00s OpenSSL 1.0.2 22 Jan 2015 built on: reproducible build, date unspecified options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx) compiler: gcc -I. -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT(quoted diff) +0
-6-DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASMThe 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128-cbc 158525.06k 214128.67k 242916.10k 250279.55k 253359.45k
----------it was got big improved with cryptodev hardware accelerator you can see from above shows
but when i configured and compiled Openvpn with
HAVE_OPENSSL_ENGINEsupported, and i can make sure Openvpn can working with cryptodev ?------
[email protected]...:/etc/openvpn# /opt/openvpn/sbin/openvpn --show-engines OpenSSL Crypto Engines
Quoted 14 lines
BSD cryptodev engine [cryptodev]
Intel RDRAND engine [rdrand]
Dynamic engine loading support [dynamic]
IBM 4758 CCA hardware engine support [4758cca]
Aep hardware engine support [aep]
Atalla hardware engine support [atalla]
CryptoSwift hardware engine support [cswift]
CHIL hardware engine support [chil]
Nuron hardware engine support [nuron]
SureWare hardware engine support [sureware]
UBSEC hardware engine support [ubsec]
Reference implementation of GOST engine [gost]
-------
what kind of hardware cryptodev accelerator is on the Intel board? how did you enable it in openssl ?
from the numbers you post I can see that there must be some external accelerator which is not part of the CPU.
OpenVPN can be made to use such accelerators but you must load the engine in OpenVPN in the right manner - which of the engines are using for your openssl test? what does
openssl engine -c -t
report?
JJK
Hi JJK,
thanks for your reply.
Quoted 1 line
Quoted 1 line
what kind of hardware cryptodev accelerator is on the Intel board? We don't have extra accelerator used in INTEL board, just enable cryptodev in kernel and installed cryptodev-linux-1.7.tar.gz , then i can got improved performance in openssl test. but i believe the cryptodev must be called CPU hardware encryption accelerator, here is my kernel configuration -----CONFIG_CRYPTO=y
## Crypto core or helper#CONFIG_CRYPTO_ALGAPI=yCONFIG_CRYPTO_ALGAPI2=yCONFIG_CRYPTO_AEAD=yCONFIG_CRYPTO_AEAD2=yCONFIG_CRYPTO_BLKCIPHER=yCONFIG_CRYPTO_BLKCIPHER2=yCONFIG_CRYPTO_HASH=yCONFIG_CRYPTO_HASH2=yCONFIG_CRYPTO_RNG=yCONFIG_CRYPTO_RNG2=yCONFIG_CRYPTO_PCOMP2=yCONFIG_CRYPTO_MANAGER=yCONFIG_CRYPTO_MANAGER2=y# CONFIG_CRYPTO_USER is not setCONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y# CONFIG_CRYPTO_GF128MUL is not set# CONFIG_CRYPTO_NULL is not set# CONFIG_CRYPTO_PCRYPT is not setCONFIG_CRYPTO_WORKQUEUE=y# CONFIG_CRYPTO_CRYPTD is not set# CONFIG_CRYPTO_MCRYPTD is not setCONFIG_CRYPTO_AUTHENC=y# CONFIG_CRYPTO_TEST is not set
## Authenticated Encryption with Associated Data#CONFIG_CRYPTO_CCM=y# CONFIG_CRYPTO_GCM is not setCONFIG_CRYPTO_SEQIV=y
## Block modes#CONFIG_CRYPTO_CBC=yCONFIG_CRYPTO_CTR=y# CONFIG_CRYPTO_CTS is not set# CONFIG_CRYPTO_ECB is not set# CONFIG_CRYPTO_LRW is not set# CONFIG_CRYPTO_PCBC is not set# CONFIG_CRYPTO_XTS is not set
## Hash modes## CONFIG_CRYPTO_CMAC is not setCONFIG_CRYPTO_HMAC=y# CONFIG_CRYPTO_XCBC is not set# CONFIG_CRYPTO_VMAC is not set## Digest#CONFIG_CRYPTO_CRC32C=y# CONFIG_CRYPTO_CRC32C_INTEL is not set# CONFIG_CRYPTO_CRC32 is not set# CONFIG_CRYPTO_CRC32_PCLMUL is not set# CONFIG_CRYPTO_CRCT10DIF is not set# CONFIG_CRYPTO_GHASH is not set# CONFIG_CRYPTO_MD4 is not setCONFIG_CRYPTO_MD5=y# CONFIG_CRYPTO_MICHAEL_MIC is not set# CONFIG_CRYPTO_RMD128 is not set# CONFIG_CRYPTO_RMD160 is not set# CONFIG_CRYPTO_RMD256 is not set# CONFIG_CRYPTO_RMD320 is not setCONFIG_CRYPTO_SHA1=y# CONFIG_CRYPTO_SHA1_SSSE3 is not set# CONFIG_CRYPTO_SHA256_SSSE3 is not set# CONFIG_CRYPTO_SHA512_SSSE3 is not set# CONFIG_CRYPTO_SHA1_MB is not setCONFIG_CRYPTO_SHA256=mCONFIG_CRYPTO_SHA512=m# CONFIG_CRYPTO_ANSI_CPRNG is not set# CONFIG_CRYPTO_DRBG_MENU is not set# CONFIG_CRYPTO_USER_API_HASH is not set# CONFIG_CRYPTO_USER_API_SKCIPHER is not setCONFIG_CRYPTO_HW=y# CONFIG_CRYPTO_DEV_PADLOCK is not set# CONFIG_CRYPTO_DEV_CCP is not setCONFIG_CRYPTO_DEV_QAT=mCONFIG_CRYPTO_DEV_QAT_DH895xCC=m# CONFIG_ASYMMETRIC_KEY_TYPE is not setCONFIG_HAVE_KVM=yCONFIG_VIRTUALIZATION=y# CONFIG_KVM is not setCONFIG_BINARY_PRINTF=y----->>how did you enable it in openssl ?i used openssl-1.0.2d and manual compile it by with "./config -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS" [email protected]...:/usr/src# /usr/local/ssl/bin/openssl engine(cryptodev) BSD cryptodev engine(rdrand) Intel RDRAND engine(dynamic) Dynamic engine loading support(4758cca) IBM 4758 CCA hardware engine support(aep) Aep hardware engine support(atalla) Atalla hardware engine support(cswift) CryptoSwift hardware engine support(chil) CHIL hardware engine support(nuron) Nuron hardware engine support(sureware) SureWare hardware engine support(ubsec) UBSEC hardware engine support(gost) Reference implementation of GOST engine----
Quoted 2 lines
Quoted 2 lines
from the numbers you post I can see that there must be some external accelerator which is not part of the CPU.there is no external accelerator, i just enable the hardware cryptodev in kernel and compiled and installed cryptodev-linux-1.7.tar.gz then insert the cryptodev.ko in test. OpenVPN can be made to use such accelerators but you must load the engine in OpenVPN in the right manner - which of the engines are using for your openssl test? what does openssl engine -c -t
report?
i think so, but why the cryptodev can not working properly, i am confused :( . and just enabled the cryptodev.ko in test. and openssl engine -c -t show as following
-------
[email protected]...:/usr/src# /usr/local/ssl/bin/openssl engine -c -t(cryptodev) BSD cryptodev engine [RSA, DSA, DH, DES-CBC, DES-EDE3-CBC, AES-128-CBC, AES-192-CBC, AES-256-CBC] [ available ](rdrand) Intel RDRAND engine [RAND] [ available ](dynamic) Dynamic engine loading support [ unavailable ](4758cca) IBM 4758 CCA hardware engine support [RSA, RAND] [ unavailable ](aep) Aep hardware engine support [RSA, DSA, DH] [ unavailable ](atalla) Atalla hardware engine support [RSA, DSA, DH] [ unavailable ](cswift) CryptoSwift hardware engine support [RSA, DSA, DH, RAND] [ unavailable ](chil) CHIL hardware engine support [RSA, DH, RAND] [ unavailable ](nuron) Nuron hardware engine support [RSA, DSA, DH] [ unavailable ](sureware) SureWare hardware engine support [RSA, DSA, DH, RAND] [ unavailable ](ubsec) UBSEC hardware engine support [RSA, DSA, DH] [ unavailable ](gost) Reference implementation of GOST engine [gost89, gost89-cnt, md_gost94, gost-mac, gost94, gost2001, gost-mac] [ available ][email protected]...:/usr/src#----any suggestion, i really need openvpn get working :( Yuqian
Hi Gert,
thanks for your reply
Quoted 1 line
Quoted 1 line
as our way to do --daemon wasn't compatible with cryptodev...do you mean it is suggested in daemon mode when running openvpn with cryptodev?
also, i found some post said the Openvpn support cryptodev is not good, as Openvpn need do lot of job copy data to/from user space to kernel, "Hoewever the user-to-kernel and kernel-to-user copying of packets (context switches) is the bottleneck. The OpenVPN speed gets capped long before the crypto accel would make a difference. Its only useful for pure Kernel based VPNs like IPSec or L2TP." (source https://forum.openwrt.org/viewtopic.php?id=19586)
Thank you.
Quoted 21 lines
Date: Fri, 24 Jul 2015 10:54:54 +0200
From: [email protected]...
To: [email protected]...
CC: [email protected]
Subject: Re: [Openvpn-devel] Does Openvpn really support cryptodev hardware acceleratorsHi,
if openssl uses cryptodev, so will openvpn - we don't do our own crypto, just call the openvpn functions to do so.
(And on FreeBSD, this is the particular reason why we had so much trouble recently, as our way to do --daemon wasn't compatible with cryptodev...)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany [email protected]... fax: +49-89-35655025 [email protected]...
Hi,
Quoted 6 lines · li yuqian
Hi JJK,
thanks for your reply.
Quoted 1 line
Quoted 1 line
what kind of hardware cryptodev accelerator is on the Intel board?
We don't have extra accelerator used in INTEL board, just enable cryptodev in kernel and installed cryptodev-linux-1.7.tar.gz , then i can got improved performance in openssl test. but i believe the cryptodev must be called CPU hardware encryption accelerator, here is my kernel configuration
ah OK; I've grabbed a copy, built and installed it on 2 servers and ran some test: I get similar figures for 'openssl speed' but those numbers are artificial, i.e. they do not reflect true performance of the system. According to the site http://cryptodev-linux.org/index.html I should be getting some improvement but not *that* much.
I've built and linked openvpn against openssl 1.0.2d with the cryptodev engine enabled:
export OPENSSL_SSL_CFLAGS="-I/home/janjust/src/openssl-1.0.2d/include" export OPENSSL_SSL_LIBS="-L/home/janjust/src/openssl-1.0.2d -lssl -ldl" export OPENSSL_CRYPTO_CFLAGS="-I/home/janjust/src/openssl-1.0.2d/include" export OPENSSL_CRYPTO_LIBS="-L/home/janjust/src/openssl-1.0.2d -lcrypto -ldl" ./configure
make
Now I can run openvpn with cryptodev support enabled:
/home/janjust/src/openvpn-2.3.7-cryptodev/src/openvpn/openvpn
--ifconfig 10.200.0.1 10.200.0.2 --dev tun --secret secret.key --cipher aes-256-cbc --engine cryptodev Mon Jul 27 00:27:29 2015 OpenVPN 2.3.7 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jul 27 2015 Mon Jul 27 00:27:29 2015 library versions: OpenSSL 1.0.2d 9 Jul 2015, LZO 2.03
Mon Jul 27 00:27:29 2015 Initializing OpenSSL support for engine 'cryptodev'
....
and performance is ~ 10% higher in one direction, and actually lower in the opposite direction.
Quoted 7 lines · li yuqian
Hi Gert,
thanks for your reply
Quoted 1 line
Quoted 1 line
as our way to do --daemon wasn't compatible with cryptodev...
do you mean it is suggested in daemon mode when running openvpn with cryptodev?
Gert's comment was about freebsd crypyodev support ... on Linux openvpn 2.3.7 builds and runs just fine.
Quoted 3 lines
also, i found some post said the Openvpn support cryptodev is not good, as Openvpn need do lot of job copy data to/from user space to kernel, "Hoewever the user-to-kernel and kernel-to-user copying of packets (context switches) is the bottleneck. The OpenVPN speed gets capped long before the crypto accel would make a difference. Its only useful for pure Kernel based VPNs like IPSec or L2TP." (source https://forum.openwrt.org/viewtopic.php?id=19586)
this is partly true - openvpn minimizes the user-to-kernel and kernel-to-user copying of packets but it does happen and yes this is indeed the bottleneck. There is little we can do about this, although other tools such as vtun get slightly better performance.
My 2 servers are hooked up over gigabit ethernet, with iperf giving a nice and stable 960 Mbps without a VPN in both directions.
With openvpn and with all crypto turned off, performance drops to 350 Mbps in one direction, 370 in the other. This is due mostly to the *clockspeed* of the CPUs used (2 Xeon E5s, one is running at 2.0 GHz). If I hook up two 3.0+ GHz CPUs then openvpn without crypto will give me ~900 Mbps both ways (and with aes-256 crypto I still get a decent 560 Mbps).
What figures do you get when running openvpn with
--cipher none --auth none
?
HTH,
JJK
Quoted 168 lines
-----
CONFIG_CRYPTO=y#
# Crypto core or helper
#CONFIG_CRYPTO_ALGAPI=yCONFIG_CRYPTO_ALGAPI2=yCONFIG_CRYPTO_AEAD=yCONFIG_CRYPTO_AEAD2=yCONFIG_CRYPTO_BLKCIPHER=yCONFIG_CRYPTO_BLKCIPHER2=yCONFIG_CRYPTO_HASH=yCONFIG_CRYPTO_HASH2=yCONFIG_CRYPTO_RNG=yCONFIG_CRYPTO_RNG2=yCONFIG_CRYPTO_PCOMP2=yCONFIG_CRYPTO_MANAGER=yCONFIG_CRYPTO_MANAGER2=y
#CONFIG_CRYPTO_USERis not setCONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
#CONFIG_CRYPTO_GF128MULis not set
#CONFIG_CRYPTO_NULLis not set
#CONFIG_CRYPTO_PCRYPTis not setCONFIG_CRYPTO_WORKQUEUE=y
#CONFIG_CRYPTO_CRYPTDis not set
#CONFIG_CRYPTO_MCRYPTDis not setCONFIG_CRYPTO_AUTHENC=y
#CONFIG_CRYPTO_TESTis not set#
# Authenticated Encryption with Associated Data #CONFIG_CRYPTO_CCM=y
#CONFIG_CRYPTO_GCMis not setCONFIG_CRYPTO_SEQIV=y#
# Block modes
#CONFIG_CRYPTO_CBC=yCONFIG_CRYPTO_CTR=y
#CONFIG_CRYPTO_CTSis not set
#CONFIG_CRYPTO_ECBis not set
#CONFIG_CRYPTO_LRWis not set
#CONFIG_CRYPTO_PCBCis not set
#CONFIG_CRYPTO_XTSis not set#
# Hash modes
#
#CONFIG_CRYPTO_CMACis not setCONFIG_CRYPTO_HMAC=y
#CONFIG_CRYPTO_XCBCis not set
#CONFIG_CRYPTO_VMACis not set
#
# Digest
#CONFIG_CRYPTO_CRC32C=y
#CONFIG_CRYPTO_CRC32C_INTELis not set #CONFIG_CRYPTO_CRC32is not set
#CONFIG_CRYPTO_CRC32_PCLMULis not set #CONFIG_CRYPTO_CRCT10DIFis not set
#CONFIG_CRYPTO_GHASHis not set
#CONFIG_CRYPTO_MD4is not setCONFIG_CRYPTO_MD5=y
#CONFIG_CRYPTO_MICHAEL_MICis not set #CONFIG_CRYPTO_RMD128is not set
#CONFIG_CRYPTO_RMD160is not set
#CONFIG_CRYPTO_RMD256is not set
#CONFIG_CRYPTO_RMD320is not setCONFIG_CRYPTO_SHA1=y
#CONFIG_CRYPTO_SHA1_SSSE3is not set
#CONFIG_CRYPTO_SHA256_SSSE3is not set #CONFIG_CRYPTO_SHA512_SSSE3is not set #CONFIG_CRYPTO_SHA1_MBis not setCONFIG_CRYPTO_SHA256=mCONFIG_CRYPTO_SHA512=m
#CONFIG_CRYPTO_ANSI_CPRNGis not set
#CONFIG_CRYPTO_DRBG_MENUis not set
#CONFIG_CRYPTO_USER_API_HASHis not set #CONFIG_CRYPTO_USER_API_SKCIPHERis not setCONFIG_CRYPTO_HW=y
#CONFIG_CRYPTO_DEV_PADLOCKis not set #CONFIG_CRYPTO_DEV_CCPis not setCONFIG_CRYPTO_DEV_QAT=mCONFIG_CRYPTO_DEV_QAT_DH895xCC=m
#CONFIG_ASYMMETRIC_KEY_TYPEis not setCONFIG_HAVE_KVM=yCONFIG_VIRTUALIZATION=y
#CONFIG_KVMis not setCONFIG_BINARY_PRINTF=y
-----Quoted 1 line
Quoted 1 line
how did you enable it in openssl ?
i used openssl-1.0.2d and manual compile it by with "./config -DHAVE_CRYPTODEV -DUSE_CRYPTDEV_DIGESTS"
----[email protected]...:/usr/src# /usr/local/ssl/bin/openssl engine (cryptodev) BSD cryptodev engine (rdrand) Intel RDRAND engine (dynamic) Dynamic engine loading support (4758cca) IBM 4758 CCA hardware engine support (aep) Aep hardware engine support (atalla) Atalla hardware engine support (cswift) CryptoSwift hardware engine support (chil) CHIL hardware engine support (nuron) Nuron hardware engine support (sureware) SureWare hardware engine support (ubsec) UBSEC hardware engine support (gost) Reference implementation of GOST engine ----Quoted 1 line
Quoted 1 line
from the numbers you post I can see that there must be some external
accelerator which is not part of the CPU.
there is no external accelerator, i just enable the hardware cryptodev in kernel and compiled and installed cryptodev-linux-1.7.tar.gz then insert the cryptodev.ko in test.Quoted 1 line
Quoted 1 line
OpenVPN can be made to use such accelerators but you must load the engine in OpenVPN in
the right manner - which of the engines are using for your openssl test? what does
openssl engine -c -t
report?i think so, but why the cryptodev can not working properly, i am confused :( . and just enabled the cryptodev.ko in test. and openssl engine -c -t show as following
-------[email protected]...:/usr/src# /usr/local/ssl/bin/openssl engine -c -t (cryptodev) BSD cryptodev engine [RSA, DSA, DH, DES-CBC, DES-EDE3-CBC, AES-128-CBC, AES-192-CBC, AES-256-CBC] [ available ] (rdrand) Intel RDRAND engine [RAND] [ available ] (dynamic) Dynamic engine loading support [ unavailable ] (4758cca) IBM 4758 CCA hardware engine support [RSA, RAND] [ unavailable ] (aep) Aep hardware engine support [RSA, DSA, DH] [ unavailable ] (atalla) Atalla hardware engine support [RSA, DSA, DH] [ unavailable ] (cswift) CryptoSwift hardware engine support [RSA, DSA, DH, RAND] [ unavailable ] (chil) CHIL hardware engine support [RSA, DH, RAND] [ unavailable ] (nuron) Nuron hardware engine support [RSA, DSA, DH] [ unavailable ] (sureware) SureWare hardware engine support [RSA, DSA, DH, RAND] [ unavailable ] (ubsec) UBSEC hardware engine support [RSA, DSA, DH] [ unavailable ] (gost) Reference implementation of GOST engine [gost89, gost89-cnt, md_gost94, gost-mac, gost94, gost2001, gost-mac] [ available ] [email protected]...:/usr/src# ---- any suggestion, i really need openvpn get working :(Yuqian
------------------------------------------------------------------------
Hi Jan,
Thanks for your replay :)
Quoted 1 line
Quoted 1 line
ah OK; I've grabbed a copy, built and installed it on 2 servers and ran some test: I get similar figures for 'openssl speed' but those numbers are artificial, i.e. they do not reflect true performance of the system. According to the site http://cryptodev-linux.org/index.html I should be getting some improvement but not *that* much.
i think the cryptodev got much improved with enabled it, take a look for following what i got test data-------------without cryptodev-------------The 'numbers' are in 1000s of bytes per second processed.type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytesaes-128-cbc 158525.06k 214128.67k 242916.10k 250279.55k 253359.45k-------------with cryptodev-------------The 'numbers' are in 1000s of bytes per second processed.type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytesaes-128-cbc 45084.53k 191286.30k 656871.75k 3228385.28k 18282905.60k--------------compare the 8192 bytes per second processed, with cryptodev up to 18282905.60k, without is only 253359.45k, this is very good improved. don't look at that times of openssl speed -evp aes-128-cbc
Quoted 1 line
Quoted 1 line
this is partly true - openvpn minimizes the user-to-kernel and kernel-to-user copying of packets but it does happen and yes this is indeed the bottleneck. There is little we can do about this, although other tools such as vtun get slightly better performance.
do you mean if we want through "hardware encryption accelerator <--> cryptodev(kernel) <--> openvpn(user space)" is not good as the bottleneck existed? what is your suggestion? how about we do that in this way "hardware encryption accelerator <--> openvpn(user space)" that mean we customize Openvpn let it call to CPU manufacturer provides API by directly? Thank you very much.
Yuqian
Hi,
Quoted 6 lines · Jan Just Keijser
Quoted 4 lines
Quoted 1 line
Quoted 1 line
as our way to do --daemon wasn't compatible with cryptodev...
do you mean it is suggested in daemon mode when running openvpn with cryptodev?
Gert's comment was about freebsd crypyodev support ... on Linux openvpn 2.3.7 builds and runs just fine.
2.3.*7* has the same issues everywhere, that --daemon and passphrase- protected keys just do not work together anymore... (already fixed in git)
Up to 2.3.6 had the issue *on FreeBSD* that cryptodev + --daemon did not work together - which would not have been such a big issue, *if* the FreeBSD people hadn't decided to always enable cryptodev in openssl (so, no --engine cryptodev needed)...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 18 lines · li yuqian
Hi Jan,
Thanks for your replay :)
Quoted 1 line
Quoted 1 line
ah OK; I've grabbed a copy, built and installed it on 2 servers and
ran some test: I get similar figures for 'openssl speed' but those numbers are artificial, i.e. they do not reflect true performance of the system. According to the sitehttp://cryptodev-linux.org/index.htmlI should be getting some improvement but not *that* much.
i think the cryptodev got much improved with enabled it, take a look for following what i got test data
-------------
without cryptodev
-------------
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128-cbc 158525.06k 214128.67k 242916.10k 250279.55k 253359.45k
-------------
with cryptodev
-------------
The 'numbers' are in 1000s of bytes per second processed.
Quoted 6 lines
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes aes-128-cbc 45084.53k 191286.30k 656871.75k 3228385.28k 18282905.60k--------------
compare the 8192 bytes per second processed, with cryptodev up to 18282905.60k, without is only 253359.45k, this is very good improved. don't look at that times of openssl speed -evp aes-128-cbc
as I wrote in another mail on this list, it's not openvpn but the 'openssl speed' command which fails here:
Try running this openssl command on your box:
date ; cat bigfile | openssl enc -e -aes-256-cbc -bufsize 8192 -pass pass:testing123 > /dev/null ; date
where 'bigfile' is some large file of > 2 GB in size. Then rerun it using
date ; cat bigfile | openssl enc -engine cryptodev -e -aes-256-cbc -bufsize 8192 -pass pass:testing123 > /dev/null ; date
and compare the results of the dates of 'before' and 'after'. On my hardware I takes ~ 10 seconds to encrypt a 3.3 GB file , with zero difference whether I use cryptodev or not, whereas 'openssl speed' reports a 100+ % improvement:
with cryptodev module loaded:
aes-256-cbc 286337.65k 1048423.31k 4589489.60k 19596646.40k
141238272.00k
without cryptodev:
aes-256-cbc 465276.57k 487043.33k 493990.87k 493776.90k
495720.11k
so, apart from the fact that openvpn's speed limitations are not determined solely by encryption/decryption, this does prove to me that the cryptodev device offers little if no performance improvement.
hope this clears things up,
JJK