From 3d027d4d60d37de89eaebf2d106ec0c6a492db72 Mon Sep 17 00:00:00 2001 From: Julia Kartseva Date: Mon, 19 Apr 2021 13:27:07 -0700 Subject: shared, bpf: add bpf link serialization core: serialize socket_bind bpf links --- src/shared/bpf-link.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/shared/bpf-link.c') diff --git a/src/shared/bpf-link.c b/src/shared/bpf-link.c index 94d1a8c7ac..f718cb7d2d 100644 --- a/src/shared/bpf-link.c +++ b/src/shared/bpf-link.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #include "bpf-link.h" +#include "serialize.h" bool can_link_bpf_program(struct bpf_program *prog) { _cleanup_(bpf_link_freep) struct bpf_link *link = NULL; @@ -14,6 +15,21 @@ bool can_link_bpf_program(struct bpf_program *prog) { return libbpf_get_error(link) == -EBADF; } +int serialize_bpf_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *link) { + int fd; + + assert(key); + + if (!link) + return -ENOENT; + + if (libbpf_get_error(link) != 0) + return -EINVAL; + + fd = bpf_link__fd(link); + return serialize_fd(f, fds, key, fd); +} + struct bpf_link *bpf_link_free(struct bpf_link *link) { /* bpf_link__destroy handles link == NULL case */ (void) bpf_link__destroy(link); -- cgit v1.2.1