libbpf: Factor out common logic of testing and closing FD

Factor out common piece of logic that detects support for a feature based on
successfully created FD. Also take care of closing FD, if it was created.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200818213356.2629020-4-andriin@fb.com
This commit is contained in:
Andrii Nakryiko 2020-08-18 14:33:52 -07:00 • committed by Alexei Starovoitov
commit bb180fb240