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()
154 * Add key=1 (+1 key)
155 * Add key=2 (+1 key)
156 * Lookup Key=1
157 * Add Key=3
158 * => Key=2 will be removed by LRU
159 * Iterate map. Only found key=1 and key=3
163 unsigned long long key, value[nr_cpus]; in test_lru_sanity0() local
183 /* insert key=1 element */ in test_lru_sanity0()
185 key = 1; in test_lru_sanity0()
186 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
187 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
191 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity0()
192 /* key=1 already exists */ in test_lru_sanity0()
194 assert(bpf_map_update_elem(lru_map_fd, &key, value, -1) == -EINVAL); 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) == -ENOENT); in test_lru_sanity0()
203 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity0()
204 /* key=2 is not there */ in test_lru_sanity0()
206 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
208 /* insert key=3 element */ in test_lru_sanity0()
210 /* check that key=3 is not found */ in test_lru_sanity0()
211 key = 3; in test_lru_sanity0()
212 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity0()
214 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity0()
215 * stop LRU from removing key=1 in test_lru_sanity0()
217 key = 1; in test_lru_sanity0()
218 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity0()
221 key = 3; in test_lru_sanity0()
222 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity0()
223 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity0()
226 /* key=2 has been removed from the LRU */ in test_lru_sanity0()
227 key = 2; in test_lru_sanity0()
228 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity0()
230 /* lookup elem key=1 and delete it, then check it doesn't exist */ in test_lru_sanity0()
231 key = 1; in test_lru_sanity0()
232 assert(!bpf_map_lookup_and_delete_elem(lru_map_fd, &key, &value)); in test_lru_sanity0()
236 assert(!bpf_map_delete_elem(expected_map_fd, &key)); in test_lru_sanity0()
254 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity1() local
283 for (key = 1; key < end_key; key++) in test_lru_sanity1()
284 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
289 for (key = 1; key < end_key; key++) { in test_lru_sanity1()
290 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity1()
291 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
300 key = 1 + __map_size(tgt_free); in test_lru_sanity1()
301 end_key = key + __map_size(tgt_free); in test_lru_sanity1()
302 for (; key < end_key; key++) { in test_lru_sanity1()
303 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity1()
305 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity1()
322 unsigned long long key, value[nr_cpus]; in test_lru_sanity2() local
352 for (key = 1; key < end_key; key++) in test_lru_sanity2()
353 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
364 * Hence, the oldest key is removed from the LRU list. in test_lru_sanity2()
366 key = 1; in test_lru_sanity2()
368 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
370 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity2()
372 assert(bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
380 for (key = 1; key < end_key; key++) { in test_lru_sanity2()
381 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity2()
382 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
384 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity2()
386 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
393 key = 1 + __map_size(tgt_free); in test_lru_sanity2()
394 end_key = key + batch_size; in test_lru_sanity2()
395 for (; key < end_key; key++) in test_lru_sanity2()
399 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
404 for (; key < end_key; key++) { in test_lru_sanity2()
405 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity2()
407 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity2()
428 unsigned long long key, end_key, value[nr_cpus]; in test_lru_sanity3() local
456 for (key = 1; key < end_key; key++) in test_lru_sanity3()
457 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
462 for (key = 1; key < end_key; key++) { in test_lru_sanity3()
463 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity3()
464 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
469 key = 2 * tgt_free + 1; in test_lru_sanity3()
470 end_key = key + batch_size; in test_lru_sanity3()
471 for (; key < end_key; key++) { in test_lru_sanity3()
472 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity3()
474 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity3()
490 unsigned long long key, value[nr_cpus]; in test_lru_sanity4() local
513 for (key = 1; key <= 2 * tgt_free; key++) in test_lru_sanity4()
514 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
517 key = 1; in test_lru_sanity4()
518 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity4()
520 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity4()
521 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity4()
522 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
526 for (; key <= 2 * tgt_free; key++) { in test_lru_sanity4()
527 assert(!bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
528 assert(bpf_map_delete_elem(lru_map_fd, &key)); in test_lru_sanity4()
531 end_key = key + 2 * tgt_free; in test_lru_sanity4()
532 for (; key < end_key; key++) { in test_lru_sanity4()
533 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity4()
535 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity4()
549 unsigned long long key, value[nr_cpus]; in do_test_lru_sanity5() local
551 /* Ensure the last key inserted by previous CPU can be found */ in do_test_lru_sanity5()
555 key = last_key + 1; in do_test_lru_sanity5()
556 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in do_test_lru_sanity5()
557 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, key, value)); in do_test_lru_sanity5()
559 /* Cannot find the last key because it was removed by LRU */ in do_test_lru_sanity5()
566 unsigned long long key, value[nr_cpus]; in test_lru_sanity5() local
580 key = 0; in test_lru_sanity5()
581 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity5()
588 do_test_lru_sanity5(key, map_fd); in test_lru_sanity5()
591 printf("couldn't spawn process to test key:%llu\n", in test_lru_sanity5()
592 key); in test_lru_sanity5()
599 key++; in test_lru_sanity5()
604 /* At least one key should be tested */ in test_lru_sanity5()
605 assert(key > 0); in test_lru_sanity5()
614 unsigned long long key, value[nr_cpus]; in test_lru_sanity6() local
634 for (key = 1; key <= tgt_free; key++) { in test_lru_sanity6()
635 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
637 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
641 for (; key <= tgt_free * 2; key++) { in test_lru_sanity6()
644 /* Make ref bit sticky for key: [1, tgt_free] */ in test_lru_sanity6()
650 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
654 for (; key <= tgt_free * 3; key++) { in test_lru_sanity6()
655 assert(!bpf_map_update_elem(lru_map_fd, &key, value, in test_lru_sanity6()
657 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity6()
670 * Add key=1 (+1 key)
671 * Add key=2 (+1 key)
672 * Lookup Key=1 (datapath)
673 * Lookup Key=2 (syscall)
674 * Add Key=3
675 * => Key=2 will be removed by LRU
676 * Iterate map. Only found key=1 and key=3
680 unsigned long long key, value[nr_cpus]; in test_lru_sanity7() local
700 /* insert key=1 element */ in test_lru_sanity7()
702 key = 1; in test_lru_sanity7()
703 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
704 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
708 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity7()
709 /* key=1 already exists */ in test_lru_sanity7()
711 /* insert key=2 element */ in test_lru_sanity7()
713 /* check that key=2 is not found */ in test_lru_sanity7()
714 key = 2; in test_lru_sanity7()
715 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
718 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity7()
719 /* key=2 is not there */ in test_lru_sanity7()
721 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
723 /* insert key=3 element */ in test_lru_sanity7()
725 /* check that key=3 is not found */ in test_lru_sanity7()
726 key = 3; in test_lru_sanity7()
727 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
729 /* check that key=1 can be found and mark the ref bit to in test_lru_sanity7()
730 * stop LRU from removing key=1 in test_lru_sanity7()
732 key = 1; in test_lru_sanity7()
733 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity7()
736 /* check that key=2 can be found and do _not_ mark ref bit. in test_lru_sanity7()
739 key = 2; in test_lru_sanity7()
740 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity7()
743 key = 3; in test_lru_sanity7()
744 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity7()
745 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity7()
748 /* key=2 has been removed from the LRU */ in test_lru_sanity7()
749 key = 2; in test_lru_sanity7()
750 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity7()
761 * Add key=1 (+1 key)
762 * Add key=2 (+1 key)
763 * Lookup Key=1 (syscall)
764 * Lookup Key=2 (datapath)
765 * Add Key=3
766 * => Key=1 will be removed by LRU
767 * Iterate map. Only found key=2 and key=3
771 unsigned long long key, value[nr_cpus]; in test_lru_sanity8() local
791 /* insert key=1 element */ in test_lru_sanity8()
793 key = 1; in test_lru_sanity8()
794 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
797 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -EEXIST); in test_lru_sanity8()
798 /* key=1 already exists */ in test_lru_sanity8()
800 /* insert key=2 element */ in test_lru_sanity8()
802 /* check that key=2 is not found */ in test_lru_sanity8()
803 key = 2; in test_lru_sanity8()
804 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()
807 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -ENOENT); in test_lru_sanity8()
808 /* key=2 is not there */ in test_lru_sanity8()
810 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
811 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
814 /* insert key=3 element */ in test_lru_sanity8()
816 /* check that key=3 is not found */ in test_lru_sanity8()
817 key = 3; in test_lru_sanity8()
818 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()
820 /* check that key=1 can be found and do _not_ mark ref bit. in test_lru_sanity8()
823 key = 1; in test_lru_sanity8()
824 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); in test_lru_sanity8()
827 /* check that key=2 can be found and mark the ref bit to in test_lru_sanity8()
828 * stop LRU from removing key=2 in test_lru_sanity8()
830 key = 2; in test_lru_sanity8()
831 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value)); in test_lru_sanity8()
834 key = 3; in test_lru_sanity8()
835 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); in test_lru_sanity8()
836 assert(!bpf_map_update_elem(expected_map_fd, &key, value, in test_lru_sanity8()
839 /* key=1 has been removed from the LRU */ in test_lru_sanity8()
840 key = 1; in test_lru_sanity8()
841 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -ENOENT); in test_lru_sanity8()