Skip to content

Commit

Permalink
[crypto] kill knet_handle_crypto compatibility wrapper
Browse files Browse the repository at this point in the history
not for stable1

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Jul 7, 2020
1 parent 1af54f0 commit 6933988
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 450 deletions.
83 changes: 4 additions & 79 deletions libknet/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,9 @@ int knet_handle_pmtud_get(knet_handle_t knet_h,
return 0;
}

static int _knet_handle_crypto_set_config(knet_handle_t knet_h,
struct knet_handle_crypto_cfg *knet_handle_crypto_cfg,
uint8_t config_num,
uint8_t force)
int knet_handle_crypto_set_config(knet_handle_t knet_h,
struct knet_handle_crypto_cfg *knet_handle_crypto_cfg,
uint8_t config_num)
{
int savederrno = 0;
int err = 0;
Expand Down Expand Up @@ -1490,7 +1489,7 @@ static int _knet_handle_crypto_set_config(knet_handle_t knet_h,
return -1;
}

if ((knet_h->crypto_in_use_config == config_num) && (!force)) {
if (knet_h->crypto_in_use_config == config_num) {
savederrno = EBUSY;
err = -1;
goto exit_unlock;
Expand Down Expand Up @@ -1534,13 +1533,6 @@ static int _knet_handle_crypto_set_config(knet_handle_t knet_h,
return err;
}

int knet_handle_crypto_set_config(knet_handle_t knet_h,
struct knet_handle_crypto_cfg *knet_handle_crypto_cfg,
uint8_t config_num)
{
return _knet_handle_crypto_set_config(knet_h, knet_handle_crypto_cfg, config_num, 0);
}

int knet_handle_crypto_rx_clear_traffic(knet_handle_t knet_h,
uint8_t value)
{
Expand Down Expand Up @@ -1607,73 +1599,6 @@ int knet_handle_crypto_use_config(knet_handle_t knet_h,
return err;
}

/*
* compatibility wrapper for 1.x releases
*/
int knet_handle_crypto(knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg)
{
int err = 0;
uint8_t value;

if (!knet_h) {
errno = EINVAL;
return -1;
}

value = knet_h->crypto_only;
/*
* configure crypto in slot 1
*/
err = _knet_handle_crypto_set_config(knet_h, knet_handle_crypto_cfg, 1, 1);
if (err < 0) {
return err;
}

if ((!strncmp("none", knet_handle_crypto_cfg->crypto_model, 4)) ||
((!strncmp("none", knet_handle_crypto_cfg->crypto_cipher_type, 4)) &&
(!strncmp("none", knet_handle_crypto_cfg->crypto_hash_type, 4)))) {
err = knet_handle_crypto_rx_clear_traffic(knet_h, KNET_CRYPTO_RX_ALLOW_CLEAR_TRAFFIC);
if (err < 0) {
return err;
}

/*
* start using clear traffic
*/
err = knet_handle_crypto_use_config(knet_h, 0);
if (err < 0) {
err = knet_handle_crypto_rx_clear_traffic(knet_h, value);
if (err < 0) {
/*
* force attempt or things will go bad
*/
knet_h->crypto_only = value;
}
}
return err;
} else {
err = knet_handle_crypto_rx_clear_traffic(knet_h, KNET_CRYPTO_RX_DISALLOW_CLEAR_TRAFFIC);
if (err < 0) {
return err;
}

/*
* start using crypto traffic
*/
err = knet_handle_crypto_use_config(knet_h, 1);
if (err < 0) {
err = knet_handle_crypto_rx_clear_traffic(knet_h, value);
if (err < 0) {
/*
* force attempt or things will go bad
*/
knet_h->crypto_only = value;
}
}
return err;
}
}

int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *knet_handle_compress_cfg)
{
int savederrno = 0;
Expand Down
28 changes: 0 additions & 28 deletions libknet/libknet.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,34 +854,6 @@ int knet_handle_crypto_rx_clear_traffic(knet_handle_t knet_h, uint8_t value);
int knet_handle_crypto_use_config(knet_handle_t knet_h,
uint8_t config_num);

/**
* knet_handle_crypto
*
* @brief set up packet cryptographic signing & encryption
*
* knet_h - pointer to knet_handle_t
*
* knet_handle_crypto_cfg -
* pointer to a knet_handle_crypto_cfg structure
* see knet_handle_crypto_set_config(3) for details.
*
*
* Implementation notes:
*
* knet_handle_crypto(3) is now a wrapper for knet_handle_crypto_set_config(3)
* and knet_handle_crypto_use_config(3) with config_num set to 1.
*
* @return
* knet_handle_crypto returns:
* @retval 0 on success
* @retval -1 on error and errno is set.
* @retval -2 on crypto subsystem initialization error. No errno is provided at the moment (yet).
*/

int knet_handle_crypto(knet_handle_t knet_h,
struct knet_handle_crypto_cfg *knet_handle_crypto_cfg);



#define KNET_COMPRESS_THRESHOLD 100

Expand Down
4 changes: 0 additions & 4 deletions libknet/tests/api-check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ api_checks = \
api_knet_handle_new_test \
api_knet_handle_free_test \
api_knet_handle_compress_test \
api_knet_handle_crypto_test \
api_knet_handle_setfwd_test \
api_knet_handle_enable_access_lists_test \
api_knet_handle_enable_filter_test \
Expand Down Expand Up @@ -93,9 +92,6 @@ api_knet_handle_new_limit_test_SOURCES = api_knet_handle_new_limit.c \
api_knet_handle_compress_test_SOURCES = api_knet_handle_compress.c \
test-common.c

api_knet_handle_crypto_test_SOURCES = api_knet_handle_crypto.c \
test-common.c

api_knet_handle_setfwd_test_SOURCES = api_knet_handle_setfwd.c \
test-common.c

Expand Down

0 comments on commit 6933988

Please sign in to comment.