Lines Matching full:key
42 static int bpf_map_lookup_elem_with_ref_bit(int fd, unsigned long long key, in bpf_map_lookup_elem_with_ref_bit() argument
48 BPF_LD_IMM64(BPF_REG_3, key), in bpf_map_lookup_elem_with_ref_bit()
103 printf("key:%llu not found from map. %s(%d)\n", in map_subset()
108 printf("key:%llu value0:%llu != value1:%llu\n", in map_subset()
141 * Add key=1 (+1 key)
142 * Add key=2 (+1 key)
143 * Lookup Key=1
144 * Add Key=3
145 * => Key=2 will be removed by LRU
146 * Iterate map. Only found key=1 and key=3
150 unsigned long long key, value[nr_cpus]; in test_lru_sanity0() local
170 /* insert key=1 element */ in test_lru_sanity0()
172 key = 1; in test_lru_sanity0()
173 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
174 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
178 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity0()
179 /* key=1 already exists */ in test_lru_sanity0()
181 assert(bpf_map_update_elem(lru_map_fd, &key, value, -1) == -EINVAL); in test_lru_sanity0()
183 /* insert key=2 element */ in test_lru_sanity0()
185 /* check that key=2 is not found */ in test_lru_sanity0()
186 key = 2; in test_lru_sanity0()
187 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity0()
190 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity0()
191 /* key=2 is not there */ in test_lru_sanity0()
193 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
195 /* insert key=3 element */ in test_lru_sanity0()
197 /* check that key=3 is not found */ in test_lru_sanity0()
198 key = 3; in test_lru_sanity0()
199 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity0()
201 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity0()
202 * stop LRU from removing key=1 in test_lru_sanity0()
204 key = 1; in test_lru_sanity0()
205 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity0()
208 key = 3; in test_lru_sanity0()
209 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
210 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
213 /* key=2 has been removed from the LRU */ in test_lru_sanity0()
214 key = 2; in test_lru_sanity0()
215 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity0()
217 /* lookup elem key=1 and delete it, then check it doesn't exist */ in test_lru_sanity0()
218 key = 1; in test_lru_sanity0()
219 assert(!bpf_map_lookup_and_delete_elem(lru_map_fd, &key, &value)); in test_lru_sanity0()
223 assert(!bpf_map_delete_elem(expected_map_fd, &key)); in test_lru_sanity0()
241 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity1() local
270 for (key = 1; key < end_key; key++) in test_lru_sanity1()
271 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
276 for (key = 1; key < end_key; key++) { in test_lru_sanity1()
277 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity1()
278 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
286 key = 1 + tgt_free; in test_lru_sanity1()
287 end_key = key + tgt_free; in test_lru_sanity1()
288 for (; key < end_key; key++) { in test_lru_sanity1()
289 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
291 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
311 * => Key 1+tgt_free to tgt_free*3/2
317 unsigned long long key, value[nr_cpus]; in test_lru_sanity2() local
347 for (key = 1; key < end_key; key++) in test_lru_sanity2()
348 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
359 * Hence, the oldest key 1 to tgt_free/2 in test_lru_sanity2()
362 key = 1; in test_lru_sanity2()
364 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
366 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity2()
368 assert(bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
377 for (key = 1; key < end_key; key++) { in test_lru_sanity2()
378 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity2()
379 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
381 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity2()
383 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
391 for (key = 1 + tgt_free; key < end_key; key++) in test_lru_sanity2()
395 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
399 end_key = key + tgt_free; in test_lru_sanity2()
400 for (; key < end_key; key++) { in test_lru_sanity2()
401 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
403 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
418 * Lookup key 1 to tgt_free*3/2
420 * => key 1+tgt_free*3/2 to 2*tgt_free are removed from LRU
424 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity3() local
453 for (key = 1; key < end_key; key++) in test_lru_sanity3()
454 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
457 /* Lookup key 1 to tgt_free*3/2 */ in test_lru_sanity3()
459 for (key = 1; key < end_key; key++) { in test_lru_sanity3()
460 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity3()
461 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
468 key = 2 * tgt_free + 1; in test_lru_sanity3()
469 end_key = key + batch_size; in test_lru_sanity3()
470 for (; key < end_key; key++) { in test_lru_sanity3()
471 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
473 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
489 unsigned long long key, value[nr_cpus]; in test_lru_sanity4() local
511 for (key = 1; key <= 2 * tgt_free; key++) in test_lru_sanity4()
512 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
515 key = 1; in test_lru_sanity4()
516 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity4()
518 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity4()
519 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity4()
520 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
524 for (; key <= 2 * tgt_free; key++) { in test_lru_sanity4()
525 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
526 assert(bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
529 end_key = key + 2 * tgt_free; in test_lru_sanity4()
530 for (; key < end_key; key++) { in test_lru_sanity4()
531 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
533 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
547 unsigned long long key, value[nr_cpus]; in do_test_lru_sanity5() local
549 /* Ensure the last key inserted by previous CPU can be found */ in do_test_lru_sanity5()
553 key = last_key + 1; in do_test_lru_sanity5()
554 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in do_test_lru_sanity5()
555 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, key, value)); in do_test_lru_sanity5()
557 /* Cannot find the last key because it was removed by LRU */ in do_test_lru_sanity5()
564 unsigned long long key, value[nr_cpus]; in test_lru_sanity5() local
578 key = 0; in test_lru_sanity5()
579 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity5()
586 do_test_lru_sanity5(key, map_fd); in test_lru_sanity5()
589 printf("couldn't spawn process to test key:%llu\n", in test_lru_sanity5()
590 key); in test_lru_sanity5()
597 key++; in test_lru_sanity5()
602 /* At least one key should be tested */ in test_lru_sanity5()
603 assert(key > 0); in test_lru_sanity5()
612 unsigned long long key, value[nr_cpus]; in test_lru_sanity6() local
632 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity6()
633 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
635 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
639 for (; key <= tgt_free * 2; key++) { in test_lru_sanity6()
642 /* Make ref bit sticky for key: [1, tgt_free] */ in test_lru_sanity6()
648 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
652 for (; key <= tgt_free * 3; key++) { in test_lru_sanity6()
653 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
655 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
668 * Add key=1 (+1 key)
669 * Add key=2 (+1 key)
670 * Lookup Key=1 (datapath)
671 * Lookup Key=2 (syscall)
672 * Add Key=3
673 * => Key=2 will be removed by LRU
674 * Iterate map. Only found key=1 and key=3
678 unsigned long long key, value[nr_cpus]; in test_lru_sanity7() local
698 /* insert key=1 element */ in test_lru_sanity7()
700 key = 1; in test_lru_sanity7()
701 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
702 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
706 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity7()
707 /* key=1 already exists */ in test_lru_sanity7()
709 /* insert key=2 element */ in test_lru_sanity7()
711 /* check that key=2 is not found */ in test_lru_sanity7()
712 key = 2; in test_lru_sanity7()
713 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
716 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity7()
717 /* key=2 is not there */ in test_lru_sanity7()
719 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
721 /* insert key=3 element */ in test_lru_sanity7()
723 /* check that key=3 is not found */ in test_lru_sanity7()
724 key = 3; in test_lru_sanity7()
725 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
727 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity7()
728 * stop LRU from removing key=1 in test_lru_sanity7()
730 key = 1; in test_lru_sanity7()
731 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity7()
734 /* check that key=2 can be found and do _not_ mark ref bit. in test_lru_sanity7()
737 key = 2; in test_lru_sanity7()
738 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity7()
741 key = 3; in test_lru_sanity7()
742 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
743 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
746 /* key=2 has been removed from the LRU */ in test_lru_sanity7()
747 key = 2; in test_lru_sanity7()
748 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
759 * Add key=1 (+1 key)
760 * Add key=2 (+1 key)
761 * Lookup Key=1 (syscall)
762 * Lookup Key=2 (datapath)
763 * Add Key=3
764 * => Key=1 will be removed by LRU
765 * Iterate map. Only found key=2 and key=3
769 unsigned long long key, value[nr_cpus]; in test_lru_sanity8() local
789 /* insert key=1 element */ in test_lru_sanity8()
791 key = 1; in test_lru_sanity8()
792 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
795 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity8()
796 /* key=1 already exists */ in test_lru_sanity8()
798 /* insert key=2 element */ in test_lru_sanity8()
800 /* check that key=2 is not found */ in test_lru_sanity8()
801 key = 2; in test_lru_sanity8()
802 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()
805 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity8()
806 /* key=2 is not there */ in test_lru_sanity8()
808 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
809 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
812 /* insert key=3 element */ in test_lru_sanity8()
814 /* check that key=3 is not found */ in test_lru_sanity8()
815 key = 3; in test_lru_sanity8()
816 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()
818 /* check that key=1 can be found and do _not_ mark ref bit. in test_lru_sanity8()
821 key = 1; in test_lru_sanity8()
822 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity8()
825 /* check that key=2 can be found and mark the ref bit to in test_lru_sanity8()
826 * stop LRU from removing key=2 in test_lru_sanity8()
828 key = 2; in test_lru_sanity8()
829 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity8()
832 key = 3; in test_lru_sanity8()
833 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
834 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
837 /* key=1 has been removed from the LRU */ in test_lru_sanity8()
838 key = 1; in test_lru_sanity8()
839 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()