MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_specific

Function add_specific

dpdk/lib/ipsec/ipsec_sad.c:66–114  ·  view source on GitHub ↗

* @internal helper function * Add a rule of type SPI_DIP or SPI_DIP_SIP. * Inserts a rule into an appropriate hash table, * updates the value for a given SPI in SPI_ONLY hash table * reflecting presence of more specific rule type in two LSBs. * Updates a counter that reflects the number of rules with the same SPI. */

Source from the content-addressed store, hash-verified

64 * Updates a counter that reflects the number of rules with the same SPI.
65 */
66static inline int
67add_specific(struct rte_ipsec_sad *sad, const void *key,
68 int key_type, void *sa)
69{
70 void *tmp_val;
71 int ret, notexist;
72
73 /* Check if the key is present in the table.
74 * Need for further accaunting in cnt_arr
75 */
76 ret = rte_hash_lookup_with_hash(sad->hash[key_type], key,
77 rte_hash_crc(key, sad->keysize[key_type], sad->init_val));
78 notexist = (ret == -ENOENT);
79
80 /* Add an SA to the corresponding table.*/
81 ret = rte_hash_add_key_with_hash_data(sad->hash[key_type], key,
82 rte_hash_crc(key, sad->keysize[key_type], sad->init_val), sa);
83 if (ret != 0)
84 return ret;
85
86 /* Check if there is an entry in SPI only table with the same SPI */
87 ret = rte_hash_lookup_with_hash_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY],
88 key, rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
89 sad->init_val), &tmp_val);
90 if (ret < 0)
91 tmp_val = NULL;
92 tmp_val = SET_BIT(tmp_val, key_type);
93
94 /* Add an entry into SPI only table */
95 ret = rte_hash_add_key_with_hash_data(
96 sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
97 rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
98 sad->init_val), tmp_val);
99 if (ret != 0)
100 return ret;
101
102 /* Update a counter for a given SPI */
103 ret = rte_hash_lookup_with_hash(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key,
104 rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY],
105 sad->init_val));
106 if (ret < 0)
107 return ret;
108 if (key_type == RTE_IPSEC_SAD_SPI_DIP)
109 sad->cnt_arr[ret].cnt_dip += notexist;
110 else
111 sad->cnt_arr[ret].cnt_dip_sip += notexist;
112
113 return 0;
114}
115
116int
117rte_ipsec_sad_add(struct rte_ipsec_sad *sad,

Callers 1

rte_ipsec_sad_addFunction · 0.85

Calls 4

rte_hash_crcFunction · 0.85

Tested by

no test coverage detected