Skip to content

Commit

Permalink
examples/ipsec-secgw: revert SA salt endianness
Browse files Browse the repository at this point in the history
[ upstream commit 7f9b2c9 ]

The previous commit swapped the bytes of SA salt which
led to incorrect work of the ipsec-secgw application.
This patch reverts the previous commit and changes
the type of the salt field in the ipsec_sa structure.

Fixes: e6bfd96 ("examples/ipsec-secgw: fix SA salt endianness")

Signed-off-by: Vladimir Medvedkin <[email protected]>
Acked-by: Radu Nicolau <[email protected]>
  • Loading branch information
vmedvedk authored and kevintraynor committed Aug 23, 2024
1 parent 1ab70cd commit 698684c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/ipsec-secgw/ipsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct ipsec_sa {
uint32_t spi;
uint32_t cdev_id_qp;
uint64_t seq;
uint32_t salt;
rte_be32_t salt;
uint32_t fallback_sessions;
enum rte_crypto_cipher_algorithm cipher_algo;
enum rte_crypto_auth_algorithm auth_algo;
Expand Down
13 changes: 6 additions & 7 deletions examples/ipsec-secgw/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
uint32_t ti; /*token index*/
uint32_t *ri /*rule index*/;
struct ipsec_sa_cnt *sa_cnt;
rte_be32_t salt; /*big-endian salt*/
uint32_t cipher_algo_p = 0;
uint32_t auth_algo_p = 0;
uint32_t aead_algo_p = 0;
Expand Down Expand Up @@ -500,8 +499,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
if (algo->algo == RTE_CRYPTO_CIPHER_AES_CTR) {
key_len -= 4;
rule->cipher_key_len = key_len;
memcpy(&salt, &rule->cipher_key[key_len], 4);
rule->salt = rte_be_to_cpu_32(salt);
memcpy(&rule->salt,
&rule->cipher_key[key_len], 4);
}

cipher_algo_p = 1;
Expand Down Expand Up @@ -565,8 +564,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
key_len -= 4;
rule->auth_key_len = key_len;
rule->iv_len = algo->iv_len;
memcpy(&salt, &rule->auth_key[key_len], 4);
rule->salt = rte_be_to_cpu_32(salt);
memcpy(&rule->salt,
&rule->auth_key[key_len], 4);
}

auth_algo_p = 1;
Expand Down Expand Up @@ -624,8 +623,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,

key_len -= 4;
rule->cipher_key_len = key_len;
memcpy(&salt, &rule->cipher_key[key_len], 4);
rule->salt = rte_be_to_cpu_32(salt);
memcpy(&rule->salt,
&rule->cipher_key[key_len], 4);

aead_algo_p = 1;
continue;
Expand Down

0 comments on commit 698684c

Please sign in to comment.