lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191127094837.4045-3-jolsa@kernel.org>
Date:   Wed, 27 Nov 2019 10:48:36 +0100
From:   Jiri Olsa <jolsa@...nel.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Michael Petlan <mpetlan@...hat.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Alexei Starovoitov <alexei.starovoitov@...il.com>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>
Subject: [PATCH 2/3] libbpf: Export netlink functions used by bpftool

From: Toke Høiland-Jørgensen <toke@...hat.com>

There are a couple of netlink-related symbols in libbpf that is used by
bpftool, but not exported in the .so version of libbpf. This makes it
impossible to link bpftool dynamically against libbpf. Fix this by adding
the missing function exports.

Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
---
 tools/lib/bpf/libbpf.h   | 22 +++++++++++++---------
 tools/lib/bpf/libbpf.map |  7 +++++++
 tools/lib/bpf/nlattr.h   | 15 ++++++++++-----
 3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 0dbf4bfba0c4..ba32eb0b2b99 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -514,15 +514,19 @@ bpf_perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size,
 
 struct nlattr;
 typedef int (*libbpf_dump_nlmsg_t)(void *cookie, void *msg, struct nlattr **tb);
-int libbpf_netlink_open(unsigned int *nl_pid);
-int libbpf_nl_get_link(int sock, unsigned int nl_pid,
-		       libbpf_dump_nlmsg_t dump_link_nlmsg, void *cookie);
-int libbpf_nl_get_class(int sock, unsigned int nl_pid, int ifindex,
-			libbpf_dump_nlmsg_t dump_class_nlmsg, void *cookie);
-int libbpf_nl_get_qdisc(int sock, unsigned int nl_pid, int ifindex,
-			libbpf_dump_nlmsg_t dump_qdisc_nlmsg, void *cookie);
-int libbpf_nl_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle,
-			 libbpf_dump_nlmsg_t dump_filter_nlmsg, void *cookie);
+LIBBPF_API int libbpf_netlink_open(unsigned int *nl_pid);
+LIBBPF_API int libbpf_nl_get_link(int sock, unsigned int nl_pid,
+				  libbpf_dump_nlmsg_t dump_link_nlmsg,
+				  void *cookie);
+LIBBPF_API int libbpf_nl_get_class(int sock, unsigned int nl_pid, int ifindex,
+				   libbpf_dump_nlmsg_t dump_class_nlmsg,
+				   void *cookie);
+LIBBPF_API int libbpf_nl_get_qdisc(int sock, unsigned int nl_pid, int ifindex,
+				   libbpf_dump_nlmsg_t dump_qdisc_nlmsg,
+				   void *cookie);
+LIBBPF_API int libbpf_nl_get_filter(int sock, unsigned int nl_pid, int ifindex,
+				    int handle, libbpf_dump_nlmsg_t dump_filter_nlmsg,
+				    void *cookie);
 
 struct bpf_prog_linfo;
 struct bpf_prog_info;
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
index 8ddc2c40e482..fbd08911ec9e 100644
--- a/tools/lib/bpf/libbpf.map
+++ b/tools/lib/bpf/libbpf.map
@@ -207,4 +207,11 @@ LIBBPF_0.0.6 {
 		bpf_program__size;
 		btf__find_by_name_kind;
 		libbpf_find_vmlinux_btf_id;
+		libbpf_netlink_open;
+		libbpf_nl_get_class;
+		libbpf_nl_get_filter;
+		libbpf_nl_get_link;
+		libbpf_nl_get_qdisc;
+		libbpf_nla_parse;
+		libbpf_nla_parse_nested;
 } LIBBPF_0.0.5;
diff --git a/tools/lib/bpf/nlattr.h b/tools/lib/bpf/nlattr.h
index 6cc3ac91690f..91119ff5701a 100644
--- a/tools/lib/bpf/nlattr.h
+++ b/tools/lib/bpf/nlattr.h
@@ -14,6 +14,10 @@
 /* avoid multiple definition of netlink features */
 #define __LINUX_NETLINK_H
 
+#ifndef LIBBPF_API
+#define LIBBPF_API __attribute__((visibility("default")))
+#endif
+
 /**
  * Standard attribute types to specify validation policy
  */
@@ -95,11 +99,12 @@ static inline int libbpf_nla_len(const struct nlattr *nla)
 	return nla->nla_len - NLA_HDRLEN;
 }
 
-int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head,
-		     int len, struct libbpf_nla_policy *policy);
-int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype,
-			    struct nlattr *nla,
-			    struct libbpf_nla_policy *policy);
+LIBBPF_API int libbpf_nla_parse(struct nlattr *tb[], int maxtype,
+				struct nlattr *head, int len,
+				struct libbpf_nla_policy *policy);
+LIBBPF_API int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype,
+				       struct nlattr *nla,
+				       struct libbpf_nla_policy *policy);
 
 int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh);
 
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ