/* check that same map ID was reused for second load */
map_id2 = get_map_id(obj, "pinmap"); if (CHECK(map_id != map_id2, "check reuse", "err %d errno %d id %d id2 %d\n", err, errno, map_id, map_id2)) goto out;
/* should be no-op to re-pin same map */
map = bpf_object__find_map_by_name(obj, "pinmap"); if (CHECK(!map, "find map", "NULL map")) goto out;
/* get pinning path */ if (!ASSERT_STREQ(bpf_map__pin_path(map), pinpath, "get pin path")) goto out;
/* set pinning path of other map and re-pin all */
map = bpf_object__find_map_by_name(obj, "nopinmap"); if (CHECK(!map, "find map", "NULL map")) goto out;
/* get pinning path after set */ if (!ASSERT_STREQ(bpf_map__pin_path(map), custpinpath, "get pin path after set")) goto out;
/* should only pin the one unpinned map */
err = bpf_object__pin_maps(obj, NULL); if (CHECK(err, "pin maps", "err %d errno %d\n", err, errno)) goto out;
/* check that nopinmap was pinned at the custom path */
err = stat(custpinpath, &statbuf); if (CHECK(err, "stat custpinpath", "err %d errno %d\n", err, errno)) goto out;
/* remove the custom pin path to re-test it with auto-pinning below */
err = unlink(custpinpath); if (CHECK(err, "unlink custpinpath", "err %d errno %d\n", err, errno)) goto out;
/* open the valid object file again */
obj = bpf_object__open_file(file, NULL);
err = libbpf_get_error(obj); if (CHECK(err, "default open", "err %d errno %d\n", err, errno)) {
obj = NULL; goto out;
}
/* set pin paths so that nopinmap2 will attempt to reuse the map at * pinpath (which will fail), but not before pinmap has already been * reused
*/
bpf_object__for_each_map(map, obj) { if (!strcmp(bpf_map__name(map), "nopinmap"))
err = bpf_map__set_pin_path(map, nopinpath2); elseif (!strcmp(bpf_map__name(map), "nopinmap2"))
err = bpf_map__set_pin_path(map, pinpath); else continue;
/* should fail because of map parameter mismatch */
err = bpf_object__load(obj); if (CHECK(err != -EINVAL, "param mismatch load", "err %d errno %d\n", err, errno)) goto out;
/* nopinmap2 should have been pinned and cleaned up again */
err = stat(nopinpath2, &statbuf); if (CHECK(!err || errno != ENOENT, "stat nopinpath2", "err %d errno %d\n", err, errno)) goto out;
/* pinmap should still be there */
err = stat(pinpath, &statbuf); if (CHECK(err, "stat pinpath", "err %d errno %d\n", err, errno)) goto out;
bpf_object__close(obj);
/* test auto-pinning at custom path with open opt */
obj = bpf_object__open_file(file, &opts); if (CHECK_FAIL(libbpf_get_error(obj))) {
obj = NULL; goto out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.