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
50 BPF_LD_IMM64(BPF_REG_3, key), in bpf_map_lookup_elem_with_ref_bit()
114 printf("key:%llu not found from map. %s(%d)\n", in map_subset()
119 printf("key:%llu value0:%llu != value1:%llu\n", in map_subset()
152 * Add key=1 (+1 key)
153 * Add key=2 (+1 key)
154 * Lookup Key=1
155 * Add Key=3
156 * => Key=2 will be removed by LRU
157 * Iterate map. Only found key=1 and key=3
161 unsigned long long key, value[nr_cpus]; in test_lru_sanity0() local
181 /* insert key=1 element */ in test_lru_sanity0()
183 key = 1; in test_lru_sanity0()
184 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
185 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
189 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1 in test_lru_sanity0()
190 /* key=1 already exists */ in test_lru_sanity0()
193 assert(bpf_map_update_elem(lru_map_fd, &key, value, -1) == -1 && in test_lru_sanity0()
196 /* insert key=2 element */ in test_lru_sanity0()
198 /* check that key=2 is not found */ in test_lru_sanity0()
199 key = 2; in test_lru_sanity0()
200 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity0()
204 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 && in test_lru_sanity0()
205 /* key=2 is not there */ in test_lru_sanity0()
208 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
210 /* insert key=3 element */ in test_lru_sanity0()
212 /* check that key=3 is not found */ in test_lru_sanity0()
213 key = 3; in test_lru_sanity0()
214 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity0()
217 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity0()
218 * stop LRU from removing key=1 in test_lru_sanity0()
220 key = 1; in test_lru_sanity0()
221 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity0()
224 key = 3; in test_lru_sanity0()
225 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
226 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
229 /* key=2 has been removed from the LRU */ in test_lru_sanity0()
230 key = 2; in test_lru_sanity0()
231 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity0()
250 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity1() local
279 for (key = 1; key < end_key; key++) in test_lru_sanity1()
280 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
285 for (key = 1; key < end_key; key++) { in test_lru_sanity1()
286 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity1()
287 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
295 key = 1 + tgt_free; in test_lru_sanity1()
296 end_key = key + tgt_free; in test_lru_sanity1()
297 for (; key < end_key; key++) { in test_lru_sanity1()
298 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
300 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
320 * => Key 1+tgt_free to tgt_free*3/2
326 unsigned long long key, value[nr_cpus]; in test_lru_sanity2() local
356 for (key = 1; key < end_key; key++) in test_lru_sanity2()
357 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
368 * Hence, the oldest key 1 to tgt_free/2 in test_lru_sanity2()
371 key = 1; in test_lru_sanity2()
373 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
375 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity2()
377 assert(bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
386 for (key = 1; key < end_key; key++) { in test_lru_sanity2()
387 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity2()
389 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
391 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity2()
393 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
401 for (key = 1 + tgt_free; key < end_key; key++) in test_lru_sanity2()
405 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
409 end_key = key + tgt_free; in test_lru_sanity2()
410 for (; key < end_key; key++) { in test_lru_sanity2()
411 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
413 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
428 * Lookup key 1 to tgt_free*3/2
430 * => key 1+tgt_free*3/2 to 2*tgt_free are removed from LRU
434 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity3() local
463 for (key = 1; key < end_key; key++) in test_lru_sanity3()
464 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
467 /* Lookup key 1 to tgt_free*3/2 */ in test_lru_sanity3()
469 for (key = 1; key < end_key; key++) { in test_lru_sanity3()
470 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity3()
471 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
478 key = 2 * tgt_free + 1; in test_lru_sanity3()
479 end_key = key + batch_size; in test_lru_sanity3()
480 for (; key < end_key; key++) { in test_lru_sanity3()
481 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
483 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
499 unsigned long long key, value[nr_cpus]; in test_lru_sanity4() local
521 for (key = 1; key <= 2 * tgt_free; key++) in test_lru_sanity4()
522 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
525 key = 1; in test_lru_sanity4()
526 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity4()
528 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity4()
529 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity4()
530 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
534 for (; key <= 2 * tgt_free; key++) { in test_lru_sanity4()
535 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
536 assert(bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
539 end_key = key + 2 * tgt_free; in test_lru_sanity4()
540 for (; key < end_key; key++) { in test_lru_sanity4()
541 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
543 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
557 unsigned long long key, value[nr_cpus]; in do_test_lru_sanity5() local
559 /* Ensure the last key inserted by previous CPU can be found */ in do_test_lru_sanity5()
563 key = last_key + 1; in do_test_lru_sanity5()
564 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in do_test_lru_sanity5()
565 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, key, value)); in do_test_lru_sanity5()
567 /* Cannot find the last key because it was removed by LRU */ in do_test_lru_sanity5()
575 unsigned long long key, value[nr_cpus]; in test_lru_sanity5() local
589 key = 0; in test_lru_sanity5()
590 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity5()
597 do_test_lru_sanity5(key, map_fd); in test_lru_sanity5()
600 printf("couldn't spawn process to test key:%llu\n", in test_lru_sanity5()
601 key); in test_lru_sanity5()
608 key++; in test_lru_sanity5()
613 /* At least one key should be tested */ in test_lru_sanity5()
614 assert(key > 0); in test_lru_sanity5()
623 unsigned long long key, value[nr_cpus]; in test_lru_sanity6() local
643 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity6()
644 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
646 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
650 for (; key <= tgt_free * 2; key++) { in test_lru_sanity6()
653 /* Make ref bit sticky for key: [1, tgt_free] */ in test_lru_sanity6()
659 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
663 for (; key <= tgt_free * 3; key++) { in test_lru_sanity6()
664 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
666 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
679 * Add key=1 (+1 key)
680 * Add key=2 (+1 key)
681 * Lookup Key=1 (datapath)
682 * Lookup Key=2 (syscall)
683 * Add Key=3
684 * => Key=2 will be removed by LRU
685 * Iterate map. Only found key=1 and key=3
689 unsigned long long key, value[nr_cpus]; in test_lru_sanity7() local
709 /* insert key=1 element */ in test_lru_sanity7()
711 key = 1; in test_lru_sanity7()
712 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
713 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
717 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1 in test_lru_sanity7()
718 /* key=1 already exists */ in test_lru_sanity7()
721 /* insert key=2 element */ in test_lru_sanity7()
723 /* check that key=2 is not found */ in test_lru_sanity7()
724 key = 2; in test_lru_sanity7()
725 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity7()
729 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 && in test_lru_sanity7()
730 /* key=2 is not there */ in test_lru_sanity7()
733 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
735 /* insert key=3 element */ in test_lru_sanity7()
737 /* check that key=3 is not found */ in test_lru_sanity7()
738 key = 3; in test_lru_sanity7()
739 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity7()
742 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity7()
743 * stop LRU from removing key=1 in test_lru_sanity7()
745 key = 1; in test_lru_sanity7()
746 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity7()
749 /* check that key=2 can be found and do _not_ mark ref bit. in test_lru_sanity7()
752 key = 2; in test_lru_sanity7()
753 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity7()
756 key = 3; in test_lru_sanity7()
757 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
758 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
761 /* key=2 has been removed from the LRU */ in test_lru_sanity7()
762 key = 2; in test_lru_sanity7()
763 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity7()
775 * Add key=1 (+1 key)
776 * Add key=2 (+1 key)
777 * Lookup Key=1 (syscall)
778 * Lookup Key=2 (datapath)
779 * Add Key=3
780 * => Key=1 will be removed by LRU
781 * Iterate map. Only found key=2 and key=3
785 unsigned long long key, value[nr_cpus]; in test_lru_sanity8() local
805 /* insert key=1 element */ in test_lru_sanity8()
807 key = 1; in test_lru_sanity8()
808 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
811 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1 in test_lru_sanity8()
812 /* key=1 already exists */ in test_lru_sanity8()
815 /* insert key=2 element */ in test_lru_sanity8()
817 /* check that key=2 is not found */ in test_lru_sanity8()
818 key = 2; in test_lru_sanity8()
819 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity8()
823 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 && in test_lru_sanity8()
824 /* key=2 is not there */ in test_lru_sanity8()
827 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
828 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
831 /* insert key=3 element */ in test_lru_sanity8()
833 /* check that key=3 is not found */ in test_lru_sanity8()
834 key = 3; in test_lru_sanity8()
835 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity8()
838 /* check that key=1 can be found and do _not_ mark ref bit. in test_lru_sanity8()
841 key = 1; in test_lru_sanity8()
842 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity8()
845 /* check that key=2 can be found and mark the ref bit to in test_lru_sanity8()
846 * stop LRU from removing key=2 in test_lru_sanity8()
848 key = 2; in test_lru_sanity8()
849 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity8()
852 key = 3; in test_lru_sanity8()
853 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
854 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
857 /* key=1 has been removed from the LRU */ in test_lru_sanity8()
858 key = 1; in test_lru_sanity8()
859 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 && in test_lru_sanity8()