test_maps.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * Testsuite for eBPF maps
  3. *
  4. * Copyright (c) 2014 PLUMgrid, http://plumgrid.com
  5. * Copyright (c) 2016 Facebook
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of version 2 of the GNU General Public
  9. * License as published by the Free Software Foundation.
  10. */
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. #include <errno.h>
  14. #include <string.h>
  15. #include <assert.h>
  16. #include <stdlib.h>
  17. #include <sys/wait.h>
  18. #include <sys/resource.h>
  19. #include <linux/bpf.h>
  20. #include <bpf/bpf.h>
  21. #include "bpf_util.h"
  22. static int map_flags;
  23. static void test_hashmap(int task, void *data)
  24. {
  25. long long key, next_key, first_key, value;
  26. int fd;
  27. fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
  28. 2, map_flags);
  29. if (fd < 0) {
  30. printf("Failed to create hashmap '%s'!\n", strerror(errno));
  31. exit(1);
  32. }
  33. key = 1;
  34. value = 1234;
  35. /* Insert key=1 element. */
  36. assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0);
  37. value = 0;
  38. /* BPF_NOEXIST means add new element if it doesn't exist. */
  39. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  40. /* key=1 already exists. */
  41. errno == EEXIST);
  42. /* -1 is an invalid flag. */
  43. assert(bpf_map_update_elem(fd, &key, &value, -1) == -1 &&
  44. errno == EINVAL);
  45. /* Check that key=1 can be found. */
  46. assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234);
  47. key = 2;
  48. /* Check that key=2 is not found. */
  49. assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT);
  50. /* BPF_EXIST means update existing element. */
  51. assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == -1 &&
  52. /* key=2 is not there. */
  53. errno == ENOENT);
  54. /* Insert key=2 element. */
  55. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0);
  56. /* key=1 and key=2 were inserted, check that key=0 cannot be
  57. * inserted due to max_entries limit.
  58. */
  59. key = 0;
  60. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  61. errno == E2BIG);
  62. /* Update existing element, though the map is full. */
  63. key = 1;
  64. assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0);
  65. key = 2;
  66. assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0);
  67. key = 3;
  68. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  69. errno == E2BIG);
  70. /* Check that key = 0 doesn't exist. */
  71. key = 0;
  72. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT);
  73. /* Iterate over two elements. */
  74. assert(bpf_map_get_next_key(fd, NULL, &first_key) == 0 &&
  75. (first_key == 1 || first_key == 2));
  76. assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 &&
  77. (next_key == first_key));
  78. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 &&
  79. (next_key == 1 || next_key == 2) &&
  80. (next_key != first_key));
  81. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 &&
  82. errno == ENOENT);
  83. /* Delete both elements. */
  84. key = 1;
  85. assert(bpf_map_delete_elem(fd, &key) == 0);
  86. key = 2;
  87. assert(bpf_map_delete_elem(fd, &key) == 0);
  88. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT);
  89. key = 0;
  90. /* Check that map is empty. */
  91. assert(bpf_map_get_next_key(fd, NULL, &next_key) == -1 &&
  92. errno == ENOENT);
  93. assert(bpf_map_get_next_key(fd, &key, &next_key) == -1 &&
  94. errno == ENOENT);
  95. close(fd);
  96. }
  97. static void test_hashmap_sizes(int task, void *data)
  98. {
  99. int fd, i, j;
  100. for (i = 1; i <= 512; i <<= 1)
  101. for (j = 1; j <= 1 << 18; j <<= 1) {
  102. fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
  103. 2, map_flags);
  104. if (fd < 0) {
  105. printf("Failed to create hashmap key=%d value=%d '%s'\n",
  106. i, j, strerror(errno));
  107. exit(1);
  108. }
  109. close(fd);
  110. usleep(10); /* give kernel time to destroy */
  111. }
  112. }
  113. static void test_hashmap_percpu(int task, void *data)
  114. {
  115. unsigned int nr_cpus = bpf_num_possible_cpus();
  116. BPF_DECLARE_PERCPU(long, value);
  117. long long key, next_key, first_key;
  118. int expected_key_mask = 0;
  119. int fd, i;
  120. fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_HASH, sizeof(key),
  121. sizeof(bpf_percpu(value, 0)), 2, map_flags);
  122. if (fd < 0) {
  123. printf("Failed to create hashmap '%s'!\n", strerror(errno));
  124. exit(1);
  125. }
  126. for (i = 0; i < nr_cpus; i++)
  127. bpf_percpu(value, i) = i + 100;
  128. key = 1;
  129. /* Insert key=1 element. */
  130. assert(!(expected_key_mask & key));
  131. assert(bpf_map_update_elem(fd, &key, value, BPF_ANY) == 0);
  132. expected_key_mask |= key;
  133. /* BPF_NOEXIST means add new element if it doesn't exist. */
  134. assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == -1 &&
  135. /* key=1 already exists. */
  136. errno == EEXIST);
  137. /* -1 is an invalid flag. */
  138. assert(bpf_map_update_elem(fd, &key, value, -1) == -1 &&
  139. errno == EINVAL);
  140. /* Check that key=1 can be found. Value could be 0 if the lookup
  141. * was run from a different CPU.
  142. */
  143. bpf_percpu(value, 0) = 1;
  144. assert(bpf_map_lookup_elem(fd, &key, value) == 0 &&
  145. bpf_percpu(value, 0) == 100);
  146. key = 2;
  147. /* Check that key=2 is not found. */
  148. assert(bpf_map_lookup_elem(fd, &key, value) == -1 && errno == ENOENT);
  149. /* BPF_EXIST means update existing element. */
  150. assert(bpf_map_update_elem(fd, &key, value, BPF_EXIST) == -1 &&
  151. /* key=2 is not there. */
  152. errno == ENOENT);
  153. /* Insert key=2 element. */
  154. assert(!(expected_key_mask & key));
  155. assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == 0);
  156. expected_key_mask |= key;
  157. /* key=1 and key=2 were inserted, check that key=0 cannot be
  158. * inserted due to max_entries limit.
  159. */
  160. key = 0;
  161. assert(bpf_map_update_elem(fd, &key, value, BPF_NOEXIST) == -1 &&
  162. errno == E2BIG);
  163. /* Check that key = 0 doesn't exist. */
  164. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT);
  165. /* Iterate over two elements. */
  166. assert(bpf_map_get_next_key(fd, NULL, &first_key) == 0 &&
  167. ((expected_key_mask & first_key) == first_key));
  168. while (!bpf_map_get_next_key(fd, &key, &next_key)) {
  169. if (first_key) {
  170. assert(next_key == first_key);
  171. first_key = 0;
  172. }
  173. assert((expected_key_mask & next_key) == next_key);
  174. expected_key_mask &= ~next_key;
  175. assert(bpf_map_lookup_elem(fd, &next_key, value) == 0);
  176. for (i = 0; i < nr_cpus; i++)
  177. assert(bpf_percpu(value, i) == i + 100);
  178. key = next_key;
  179. }
  180. assert(errno == ENOENT);
  181. /* Update with BPF_EXIST. */
  182. key = 1;
  183. assert(bpf_map_update_elem(fd, &key, value, BPF_EXIST) == 0);
  184. /* Delete both elements. */
  185. key = 1;
  186. assert(bpf_map_delete_elem(fd, &key) == 0);
  187. key = 2;
  188. assert(bpf_map_delete_elem(fd, &key) == 0);
  189. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == ENOENT);
  190. key = 0;
  191. /* Check that map is empty. */
  192. assert(bpf_map_get_next_key(fd, NULL, &next_key) == -1 &&
  193. errno == ENOENT);
  194. assert(bpf_map_get_next_key(fd, &key, &next_key) == -1 &&
  195. errno == ENOENT);
  196. close(fd);
  197. }
  198. static void test_hashmap_walk(int task, void *data)
  199. {
  200. int fd, i, max_entries = 100000;
  201. long long key, value, next_key;
  202. bool next_key_valid = true;
  203. fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
  204. max_entries, map_flags);
  205. if (fd < 0) {
  206. printf("Failed to create hashmap '%s'!\n", strerror(errno));
  207. exit(1);
  208. }
  209. for (i = 0; i < max_entries; i++) {
  210. key = i; value = key;
  211. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0);
  212. }
  213. for (i = 0; bpf_map_get_next_key(fd, !i ? NULL : &key,
  214. &next_key) == 0; i++) {
  215. key = next_key;
  216. assert(bpf_map_lookup_elem(fd, &key, &value) == 0);
  217. }
  218. assert(i == max_entries);
  219. assert(bpf_map_get_next_key(fd, NULL, &key) == 0);
  220. for (i = 0; next_key_valid; i++) {
  221. next_key_valid = bpf_map_get_next_key(fd, &key, &next_key) == 0;
  222. assert(bpf_map_lookup_elem(fd, &key, &value) == 0);
  223. value++;
  224. assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0);
  225. key = next_key;
  226. }
  227. assert(i == max_entries);
  228. for (i = 0; bpf_map_get_next_key(fd, !i ? NULL : &key,
  229. &next_key) == 0; i++) {
  230. key = next_key;
  231. assert(bpf_map_lookup_elem(fd, &key, &value) == 0);
  232. assert(value - 1 == key);
  233. }
  234. assert(i == max_entries);
  235. close(fd);
  236. }
  237. static void test_arraymap(int task, void *data)
  238. {
  239. int key, next_key, fd;
  240. long long value;
  241. fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value),
  242. 2, 0);
  243. if (fd < 0) {
  244. printf("Failed to create arraymap '%s'!\n", strerror(errno));
  245. exit(1);
  246. }
  247. key = 1;
  248. value = 1234;
  249. /* Insert key=1 element. */
  250. assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0);
  251. value = 0;
  252. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  253. errno == EEXIST);
  254. /* Check that key=1 can be found. */
  255. assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 1234);
  256. key = 0;
  257. /* Check that key=0 is also found and zero initialized. */
  258. assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 0);
  259. /* key=0 and key=1 were inserted, check that key=2 cannot be inserted
  260. * due to max_entries limit.
  261. */
  262. key = 2;
  263. assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == -1 &&
  264. errno == E2BIG);
  265. /* Check that key = 2 doesn't exist. */
  266. assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT);
  267. /* Iterate over two elements. */
  268. assert(bpf_map_get_next_key(fd, NULL, &next_key) == 0 &&
  269. next_key == 0);
  270. assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 &&
  271. next_key == 0);
  272. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 &&
  273. next_key == 1);
  274. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 &&
  275. errno == ENOENT);
  276. /* Delete shouldn't succeed. */
  277. key = 1;
  278. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == EINVAL);
  279. close(fd);
  280. }
  281. static void test_arraymap_percpu(int task, void *data)
  282. {
  283. unsigned int nr_cpus = bpf_num_possible_cpus();
  284. BPF_DECLARE_PERCPU(long, values);
  285. int key, next_key, fd, i;
  286. fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key),
  287. sizeof(bpf_percpu(values, 0)), 2, 0);
  288. if (fd < 0) {
  289. printf("Failed to create arraymap '%s'!\n", strerror(errno));
  290. exit(1);
  291. }
  292. for (i = 0; i < nr_cpus; i++)
  293. bpf_percpu(values, i) = i + 100;
  294. key = 1;
  295. /* Insert key=1 element. */
  296. assert(bpf_map_update_elem(fd, &key, values, BPF_ANY) == 0);
  297. bpf_percpu(values, 0) = 0;
  298. assert(bpf_map_update_elem(fd, &key, values, BPF_NOEXIST) == -1 &&
  299. errno == EEXIST);
  300. /* Check that key=1 can be found. */
  301. assert(bpf_map_lookup_elem(fd, &key, values) == 0 &&
  302. bpf_percpu(values, 0) == 100);
  303. key = 0;
  304. /* Check that key=0 is also found and zero initialized. */
  305. assert(bpf_map_lookup_elem(fd, &key, values) == 0 &&
  306. bpf_percpu(values, 0) == 0 &&
  307. bpf_percpu(values, nr_cpus - 1) == 0);
  308. /* Check that key=2 cannot be inserted due to max_entries limit. */
  309. key = 2;
  310. assert(bpf_map_update_elem(fd, &key, values, BPF_EXIST) == -1 &&
  311. errno == E2BIG);
  312. /* Check that key = 2 doesn't exist. */
  313. assert(bpf_map_lookup_elem(fd, &key, values) == -1 && errno == ENOENT);
  314. /* Iterate over two elements. */
  315. assert(bpf_map_get_next_key(fd, NULL, &next_key) == 0 &&
  316. next_key == 0);
  317. assert(bpf_map_get_next_key(fd, &key, &next_key) == 0 &&
  318. next_key == 0);
  319. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == 0 &&
  320. next_key == 1);
  321. assert(bpf_map_get_next_key(fd, &next_key, &next_key) == -1 &&
  322. errno == ENOENT);
  323. /* Delete shouldn't succeed. */
  324. key = 1;
  325. assert(bpf_map_delete_elem(fd, &key) == -1 && errno == EINVAL);
  326. close(fd);
  327. }
  328. static void test_arraymap_percpu_many_keys(void)
  329. {
  330. unsigned int nr_cpus = bpf_num_possible_cpus();
  331. BPF_DECLARE_PERCPU(long, values);
  332. /* nr_keys is not too large otherwise the test stresses percpu
  333. * allocator more than anything else
  334. */
  335. unsigned int nr_keys = 2000;
  336. int key, fd, i;
  337. fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key),
  338. sizeof(bpf_percpu(values, 0)), nr_keys, 0);
  339. if (fd < 0) {
  340. printf("Failed to create per-cpu arraymap '%s'!\n",
  341. strerror(errno));
  342. exit(1);
  343. }
  344. for (i = 0; i < nr_cpus; i++)
  345. bpf_percpu(values, i) = i + 10;
  346. for (key = 0; key < nr_keys; key++)
  347. assert(bpf_map_update_elem(fd, &key, values, BPF_ANY) == 0);
  348. for (key = 0; key < nr_keys; key++) {
  349. for (i = 0; i < nr_cpus; i++)
  350. bpf_percpu(values, i) = 0;
  351. assert(bpf_map_lookup_elem(fd, &key, values) == 0);
  352. for (i = 0; i < nr_cpus; i++)
  353. assert(bpf_percpu(values, i) == i + 10);
  354. }
  355. close(fd);
  356. }
  357. #define MAP_SIZE (32 * 1024)
  358. static void test_map_large(void)
  359. {
  360. struct bigkey {
  361. int a;
  362. char b[116];
  363. long long c;
  364. } key;
  365. int fd, i, value;
  366. fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
  367. MAP_SIZE, map_flags);
  368. if (fd < 0) {
  369. printf("Failed to create large map '%s'!\n", strerror(errno));
  370. exit(1);
  371. }
  372. for (i = 0; i < MAP_SIZE; i++) {
  373. key = (struct bigkey) { .c = i };
  374. value = i;
  375. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0);
  376. }
  377. key.c = -1;
  378. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  379. errno == E2BIG);
  380. /* Iterate through all elements. */
  381. assert(bpf_map_get_next_key(fd, NULL, &key) == 0);
  382. key.c = -1;
  383. for (i = 0; i < MAP_SIZE; i++)
  384. assert(bpf_map_get_next_key(fd, &key, &key) == 0);
  385. assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT);
  386. key.c = 0;
  387. assert(bpf_map_lookup_elem(fd, &key, &value) == 0 && value == 0);
  388. key.a = 1;
  389. assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == ENOENT);
  390. close(fd);
  391. }
  392. static void run_parallel(int tasks, void (*fn)(int task, void *data),
  393. void *data)
  394. {
  395. pid_t pid[tasks];
  396. int i;
  397. for (i = 0; i < tasks; i++) {
  398. pid[i] = fork();
  399. if (pid[i] == 0) {
  400. fn(i, data);
  401. exit(0);
  402. } else if (pid[i] == -1) {
  403. printf("Couldn't spawn #%d process!\n", i);
  404. exit(1);
  405. }
  406. }
  407. for (i = 0; i < tasks; i++) {
  408. int status;
  409. assert(waitpid(pid[i], &status, 0) == pid[i]);
  410. assert(status == 0);
  411. }
  412. }
  413. static void test_map_stress(void)
  414. {
  415. run_parallel(100, test_hashmap, NULL);
  416. run_parallel(100, test_hashmap_percpu, NULL);
  417. run_parallel(100, test_hashmap_sizes, NULL);
  418. run_parallel(100, test_hashmap_walk, NULL);
  419. run_parallel(100, test_arraymap, NULL);
  420. run_parallel(100, test_arraymap_percpu, NULL);
  421. }
  422. #define TASKS 1024
  423. #define DO_UPDATE 1
  424. #define DO_DELETE 0
  425. static void do_work(int fn, void *data)
  426. {
  427. int do_update = ((int *)data)[1];
  428. int fd = ((int *)data)[0];
  429. int i, key, value;
  430. for (i = fn; i < MAP_SIZE; i += TASKS) {
  431. key = value = i;
  432. if (do_update) {
  433. assert(bpf_map_update_elem(fd, &key, &value,
  434. BPF_NOEXIST) == 0);
  435. assert(bpf_map_update_elem(fd, &key, &value,
  436. BPF_EXIST) == 0);
  437. } else {
  438. assert(bpf_map_delete_elem(fd, &key) == 0);
  439. }
  440. }
  441. }
  442. static void test_map_parallel(void)
  443. {
  444. int i, fd, key = 0, value = 0;
  445. int data[2];
  446. fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
  447. MAP_SIZE, map_flags);
  448. if (fd < 0) {
  449. printf("Failed to create map for parallel test '%s'!\n",
  450. strerror(errno));
  451. exit(1);
  452. }
  453. /* Use the same fd in children to add elements to this map:
  454. * child_0 adds key=0, key=1024, key=2048, ...
  455. * child_1 adds key=1, key=1025, key=2049, ...
  456. * child_1023 adds key=1023, ...
  457. */
  458. data[0] = fd;
  459. data[1] = DO_UPDATE;
  460. run_parallel(TASKS, do_work, data);
  461. /* Check that key=0 is already there. */
  462. assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
  463. errno == EEXIST);
  464. /* Check that all elements were inserted. */
  465. assert(bpf_map_get_next_key(fd, NULL, &key) == 0);
  466. key = -1;
  467. for (i = 0; i < MAP_SIZE; i++)
  468. assert(bpf_map_get_next_key(fd, &key, &key) == 0);
  469. assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT);
  470. /* Another check for all elements */
  471. for (i = 0; i < MAP_SIZE; i++) {
  472. key = MAP_SIZE - i - 1;
  473. assert(bpf_map_lookup_elem(fd, &key, &value) == 0 &&
  474. value == key);
  475. }
  476. /* Now let's delete all elemenets in parallel. */
  477. data[1] = DO_DELETE;
  478. run_parallel(TASKS, do_work, data);
  479. /* Nothing should be left. */
  480. key = -1;
  481. assert(bpf_map_get_next_key(fd, NULL, &key) == -1 && errno == ENOENT);
  482. assert(bpf_map_get_next_key(fd, &key, &key) == -1 && errno == ENOENT);
  483. }
  484. static void run_all_tests(void)
  485. {
  486. test_hashmap(0, NULL);
  487. test_hashmap_percpu(0, NULL);
  488. test_hashmap_walk(0, NULL);
  489. test_arraymap(0, NULL);
  490. test_arraymap_percpu(0, NULL);
  491. test_arraymap_percpu_many_keys();
  492. test_map_large();
  493. test_map_parallel();
  494. test_map_stress();
  495. }
  496. int main(void)
  497. {
  498. struct rlimit rinf = { RLIM_INFINITY, RLIM_INFINITY };
  499. setrlimit(RLIMIT_MEMLOCK, &rinf);
  500. map_flags = 0;
  501. run_all_tests();
  502. map_flags = BPF_F_NO_PREALLOC;
  503. run_all_tests();
  504. printf("test_maps: OK\n");
  505. return 0;
  506. }