Lines Matching defs:rec

99 uint32_t sss_mc_next_slot_with_hash(struct sss_mc_rec *rec,
102 if (rec->hash1 == hash) {
103 return rec->next1;
104 } else if (rec->hash2 == hash) {
105 return rec->next2;
113 void sss_mc_chain_slot_to_record_with_hash(struct sss_mc_rec *rec,
119 if (rec->hash1 == hash) {
120 rec->next1 = slot;
121 } else if (rec->hash2 == hash) {
122 rec->next2 = slot;
204 struct sss_mc_rec *rec,
219 mcc->hash_table[hash] = MC_PTR_TO_SLOT(mcc->data_table, rec);
225 if (cur == rec) {
226 /* rec already stored in hash chain */
233 slot = MC_PTR_TO_SLOT(mcc->data_table, rec);
238 struct sss_mc_rec *rec,
246 /* It can happen if rec->hash1 and rec->hash2 was the same.
255 /* record has already been removed. It may happen if rec->hash1 and
256 * rec->has2 are the same. (It is not very likely).
261 if (cur == rec) {
262 mcc->hash_table[hash] = sss_mc_next_slot_with_hash(rec, hash);
268 if (cur == rec) {
280 static void sss_mc_free_slots(struct sss_mc_ctx *mcc, struct sss_mc_rec *rec)
286 slot = MC_PTR_TO_SLOT(mcc->data_table, rec);
287 num = MC_SIZE_TO_SLOTS(rec->len);
294 struct sss_mc_rec *rec)
296 if (rec->b1 == MC_INVALID_VAL) {
303 sss_mc_rm_rec_from_chain(mcc, rec, rec->hash1);
305 sss_mc_rm_rec_from_chain(mcc, rec, rec->hash2);
308 sss_mc_free_slots(mcc, rec);
311 MC_RAISE_INVALID_BARRIER(rec);
312 memset(rec->data, MC_INVALID_VAL8, ((MC_SLOT_SIZE * MC_SIZE_TO_SLOTS(rec->len))
314 rec->len = MC_INVALID_VAL32;
315 rec->expire = MC_INVALID_VAL64;
316 rec->next1 = MC_INVALID_VAL32;
317 rec->next2 = MC_INVALID_VAL32;
318 rec->hash1 = MC_INVALID_VAL32;
319 rec->hash2 = MC_INVALID_VAL32;
320 MC_LOWER_BARRIER(rec);
323 static bool sss_mc_is_valid_rec(struct sss_mc_ctx *mcc, struct sss_mc_rec *rec)
328 if (((uint8_t *)rec < mcc->data_table) ||
329 ((uint8_t *)rec > (mcc->data_table + mcc->dt_size - MC_SLOT_SIZE))) {
333 if ((rec->b1 == MC_INVALID_VAL) ||
334 (rec->b1 != rec->b2)) {
338 if (!MC_CHECK_RECORD_LENGTH(mcc, rec)) {
342 if (rec->expire == MC_INVALID_VAL64) {
348 if (rec->hash1 == MC_INVALID_VAL32) {
352 slot = mcc->hash_table[rec->hash1];
353 while (slot != MC_INVALID_VAL32 && self != rec) {
355 slot = sss_mc_next_slot_with_hash(self, rec->hash1);
357 if (self != rec) {
361 if (rec->hash2 != MC_INVALID_VAL32) {
363 slot = mcc->hash_table[rec->hash2];
364 while (slot != MC_INVALID_VAL32 && self != rec) {
366 slot = sss_mc_next_slot_with_hash(self, rec->hash2);
368 if (self != rec) {
383 struct sss_mc_rec *rec;
449 rec = MC_SLOT_TO_PTR(mcc->data_table, cur + i, struct sss_mc_rec);
450 if (!sss_mc_is_valid_rec(mcc, rec)) {
456 i += MC_SIZE_TO_SLOTS(rec->len) - 1;
459 sss_mc_invalidate_rec(mcc, rec);
488 struct sss_mc_rec *rec,
493 *_len = ((struct sss_mc_pwd_data *)&rec->data)->strs_len;
496 *_len = ((struct sss_mc_grp_data *)&rec->data)->strs_len;
499 *_len = ((struct sss_mc_initgr_data *)&rec->data)->data_len;
510 struct sss_mc_rec *rec;
544 rec = MC_SLOT_TO_PTR(mcc->data_table, slot, struct sss_mc_rec);
545 ret = sss_mc_get_strs_len(mcc, rec, &strs_len);
552 slot = sss_mc_next_slot_with_hash(rec, hash);
556 safealign_memcpy(&name_ptr, rec->data, sizeof(rel_ptr_t), NULL);
557 t_key = (char *)rec->data + name_ptr;
559 * payload. Since it is a pointer relative to rec->data it must be
565 || (uint8_t *)rec->data > max_addr
566 || strs_offset > max_addr - (uint8_t *)rec->data
567 || strs_len > max_addr - (uint8_t *)rec->data - strs_offset) {
580 slot = sss_mc_next_slot_with_hash(rec, hash);
587 return rec;
597 struct sss_mc_rec *rec;
631 rec = MC_SLOT_TO_PTR(mcc->data_table, base_slot, struct sss_mc_rec);
634 MC_RAISE_INVALID_BARRIER(rec);
635 rec->len = rec_len;
636 rec->next1 = MC_INVALID_VAL;
637 rec->next2 = MC_INVALID_VAL;
638 rec->padding = MC_INVALID_VAL;
639 MC_LOWER_BARRIER(rec);
646 *_rec = rec;
651 struct sss_mc_rec *rec,
656 rec->len = len;
657 rec->expire = time(NULL) + ttl;
658 rec->hash1 = sss_mc_hash(mcc, key1, key1_len);
659 rec->hash2 = sss_mc_hash(mcc, key2, key2_len);
663 struct sss_mc_rec *rec)
666 sss_mc_add_rec_to_chain(mcc, rec, rec->hash1);
668 sss_mc_add_rec_to_chain(mcc, rec, rec->hash2);
678 struct sss_mc_rec *rec;
685 rec = sss_mc_find_record(mcc, key);
686 if (rec == NULL) {
691 sss_mc_invalidate_rec(mcc, rec);
709 struct sss_mc_rec *rec;
737 ret = sss_mc_get_record(_mcc, rec_len, name, &rec);
742 data = (struct sss_mc_pwd_data *)rec->data;
745 MC_RAISE_BARRIER(rec);
748 sss_mmap_set_rec_header(mcc, rec, rec_len, mcc->valid_time_slot,
767 MC_LOWER_BARRIER(rec);
769 /* finally chain the rec in the hash table */
770 sss_mmap_chain_in_rec(mcc, rec);
783 struct sss_mc_rec *rec;
817 rec = MC_SLOT_TO_PTR(mcc->data_table, slot, struct sss_mc_rec);
818 data = (struct sss_mc_pwd_data *)(&rec->data);
824 slot = sss_mc_next_slot_with_hash(rec, hash);
832 sss_mc_invalidate_rec(mcc, rec);
852 struct sss_mc_rec *rec;
880 ret = sss_mc_get_record(_mcc, rec_len, name, &rec);
885 data = (struct sss_mc_grp_data *)rec->data;
888 MC_RAISE_BARRIER(rec);
891 sss_mmap_set_rec_header(mcc, rec, rec_len, mcc->valid_time_slot,
906 MC_LOWER_BARRIER(rec);
908 /* finally chain the rec in the hash table */
909 sss_mmap_chain_in_rec(mcc, rec);
922 struct sss_mc_rec *rec;
956 rec = MC_SLOT_TO_PTR(mcc->data_table, slot, struct sss_mc_rec);
957 data = (struct sss_mc_grp_data *)(&rec->data);
963 slot = sss_mc_next_slot_with_hash(rec, hash);
971 sss_mc_invalidate_rec(mcc, rec);
987 struct sss_mc_rec *rec;
1008 ret = sss_mc_get_record(_mcc, rec_len, unique_name, &rec);
1013 data = (struct sss_mc_initgr_data *)rec->data;
1016 MC_RAISE_BARRIER(rec);
1021 sss_mmap_set_rec_header(mcc, rec, rec_len, mcc->valid_time_slot,
1039 MC_LOWER_BARRIER(rec);
1041 /* finally chain the rec in the hash table */
1042 sss_mmap_chain_in_rec(mcc, rec);