-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1375 from tempesta-tech/ak-bn-mem-profiles
#1064: TLS performance imporovements
- Loading branch information
Showing
106 changed files
with
9,422 additions
and
11,736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
## Tempesta Kernel Emulation Unit Testing Framework | ||
# Tempesta Kernel Emulation Framework for Unit Testing | ||
|
||
This is just a set of C headers with the same names and directory hierarchies | ||
as in Linux kernel plus some additional helpers. This headers provide only most | ||
usable stubs for real kernel headers, so small and kernel modules can be | ||
compiled and tested in user space. | ||
Light-weigh Linux kernel mocking headers-only library for unit testing. | ||
Read description and comparison with other testing framework at the | ||
[Wiki](https://github.com/tempesta-tech/tempesta/wiki/Testing). | ||
|
||
See usage example in tmepesta\_db/t/tdb\_htrie.c. | ||
See usage examples in tempesta\_db/t/tdb\_htrie.c and tls/t/test\_tls.c. | ||
|
||
|
||
# Multi-processing | ||
|
||
The framework emulates 32 CPUs by default using pthreads and arrays for | ||
per-cpu variables. To use it for single-threaded testing, redefine `NR_CPUS` | ||
before the file include: | ||
```C | ||
#define NR_CPUS 1 | ||
#include "ktest.h" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2020 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __ALTERNATIVE_ASM_H__ | ||
#define __ALTERNATIVE_ASM_H__ | ||
|
||
#endif /* __ALTERNATIVE_ASM_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2020 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __EXPORT_H__ | ||
#define __EXPORT_H__ | ||
|
||
#endif /* __EXPORT_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2019 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __FPU_API_H__ | ||
#define __FPU_API_H__ | ||
|
||
/* SIMD operations are safe in user space. */ | ||
#define kernel_fpu_begin() | ||
#define kernel_fpu_end() | ||
|
||
#endif /* __FPI_API_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2020 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __NOSPEC_BRANCH_H__ | ||
#define __NOSPEC_BRANCH_H__ | ||
|
||
#define ANNOTATE_RETPOLINE_SAFE | ||
|
||
#endif /* __NOSPEC_BRANCH_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2019-2020 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __CRYPTO_HASH_H__ | ||
#define __CRYPTO_HASH_H__ | ||
|
||
#include "linux/kernel.h" | ||
#include "linux/atomic.h" | ||
|
||
#define CRYPTO_MAX_ALG_NAME 128 | ||
|
||
struct crypto_shash { /* dummy struct */ }; | ||
struct shash_desc { /* dummy struct */ }; | ||
struct crypto_tfm { /* dummy struct */ }; | ||
struct crypto_type { /* dummy struct */ }; | ||
struct ablkcipher_alg { /* dummy struct */ }; | ||
struct blkcipher_alg { /* dummy struct */ }; | ||
struct cipher_alg { /* dummy struct */ }; | ||
struct compress_alg { /* dummy struct */ }; | ||
|
||
struct crypto_alg { | ||
struct list_head cra_list; | ||
struct list_head cra_users; | ||
|
||
u32 cra_flags; | ||
unsigned int cra_blocksize; | ||
unsigned int cra_ctxsize; | ||
unsigned int cra_alignmask; | ||
|
||
int cra_priority; | ||
atomic_t cra_refcnt; | ||
|
||
char cra_name[CRYPTO_MAX_ALG_NAME]; | ||
char cra_driver_name[CRYPTO_MAX_ALG_NAME]; | ||
|
||
const struct crypto_type *cra_type; | ||
|
||
union { | ||
struct ablkcipher_alg ablkcipher; | ||
struct blkcipher_alg blkcipher; | ||
struct cipher_alg cipher; | ||
struct compress_alg compress; | ||
} cra_u; | ||
|
||
int (*cra_init)(struct crypto_tfm *tfm); | ||
void (*cra_exit)(struct crypto_tfm *tfm); | ||
void (*cra_destroy)(struct crypto_alg *alg); | ||
|
||
struct module *cra_module; | ||
} CRYPTO_MINALIGN_ATTR; | ||
|
||
struct shash_alg { | ||
int (*init)(struct shash_desc *desc); | ||
int (*update)(struct shash_desc *desc, const u8 *data, | ||
unsigned int len); | ||
int (*final)(struct shash_desc *desc, u8 *out); | ||
int (*finup)(struct shash_desc *desc, const u8 *data, | ||
unsigned int len, u8 *out); | ||
int (*digest)(struct shash_desc *desc, const u8 *data, | ||
unsigned int len, u8 *out); | ||
int (*export)(struct shash_desc *desc, void *out); | ||
int (*import)(struct shash_desc *desc, const void *in); | ||
int (*setkey)(struct crypto_shash *tfm, const u8 *key, | ||
unsigned int keylen); | ||
|
||
unsigned int descsize; | ||
|
||
/* These fields must match hash_alg_common. */ | ||
unsigned int digestsize CRYPTO_MINALIGN_ATTR; | ||
unsigned int statesize; | ||
|
||
struct crypto_alg base; | ||
}; | ||
|
||
static inline struct shash_alg *__crypto_shash_alg(struct crypto_alg *alg) | ||
{ | ||
return container_of(alg, struct shash_alg, base); | ||
} | ||
|
||
#endif /* __CRYPTO_HASH_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Tempesta kernel emulation unit testing framework. | ||
* | ||
* Copyright (C) 2019 Tempesta Technologies, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 59 | ||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
#ifndef __CRYPTO_SHA_H__ | ||
#define __CRYPTO_SHA_H__ | ||
|
||
#include "linux/compiler.h" | ||
|
||
#define SHA512_DIGEST_SIZE 64 | ||
#define SHA512_BLOCK_SIZE 128 | ||
|
||
#define SHA256_DIGEST_SIZE 32 | ||
#define SHA256_BLOCK_SIZE 64 | ||
|
||
struct sha512_state { | ||
u64 state[SHA512_DIGEST_SIZE / 8]; | ||
u64 count[2]; | ||
u8 buf[SHA512_BLOCK_SIZE]; | ||
}; | ||
|
||
struct sha256_state { | ||
u32 state[SHA256_DIGEST_SIZE / 4]; | ||
u64 count[2]; | ||
u8 buf[SHA256_BLOCK_SIZE]; | ||
}; | ||
|
||
#endif /* __CRYPTO_SHA_H__ */ |
Oops, something went wrong.