From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Joe Stringer <joe@ovn.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Wang Nan <wangnan0@huawei.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 29/29] samples/bpf: Move open_raw_sock to separate header
Date: Tue, 20 Dec 2016 14:03:58 -0300 [thread overview]
Message-ID: <20161220170358.4350-30-acme@kernel.org> (raw)
In-Reply-To: <20161220170358.4350-1-acme@kernel.org>
From: Joe Stringer <joe@ovn.org>
This function was declared in libbpf.c and was the only remaining
function in this library, but has nothing to do with BPF. Shift it out
into a new header, sock_example.h, and include it from the relevant
samples.
Signed-off-by: Joe Stringer <joe@ovn.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20161209024620.31660-8-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
samples/bpf/Makefile | 2 +-
samples/bpf/fds_example.c | 1 +
samples/bpf/libbpf.h | 3 ---
samples/bpf/sock_example.c | 1 +
samples/bpf/{libbpf.c => sock_example.h} | 3 +--
samples/bpf/sockex1_user.c | 1 +
samples/bpf/sockex2_user.c | 1 +
samples/bpf/sockex3_user.c | 1 +
8 files changed, 7 insertions(+), 6 deletions(-)
rename samples/bpf/{libbpf.c => sock_example.h} (92%)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 5a73f5a7ace1..f01b66f277b0 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -36,7 +36,7 @@ hostprogs-y += lwt_len_hist
hostprogs-y += xdp_tx_iptunnel
# Libbpf dependencies
-LIBBPF := libbpf.o ../../tools/lib/bpf/bpf.o
+LIBBPF := ../../tools/lib/bpf/bpf.o
test_lru_dist-objs := test_lru_dist.o $(LIBBPF)
sock_example-objs := sock_example.o $(LIBBPF)
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
index a5cddc99cccd..e29bd52ff9e8 100644
--- a/samples/bpf/fds_example.c
+++ b/samples/bpf/fds_example.c
@@ -14,6 +14,7 @@
#include "bpf_load.h"
#include "libbpf.h"
+#include "sock_example.h"
#define BPF_F_PIN (1 << 0)
#define BPF_F_GET (1 << 1)
diff --git a/samples/bpf/libbpf.h b/samples/bpf/libbpf.h
index 09aedc320009..3705fba453a0 100644
--- a/samples/bpf/libbpf.h
+++ b/samples/bpf/libbpf.h
@@ -185,7 +185,4 @@ struct bpf_insn;
.off = 0, \
.imm = 0 })
-/* create RAW socket and bind to interface 'name' */
-int open_raw_sock(const char *name);
-
#endif
diff --git a/samples/bpf/sock_example.c b/samples/bpf/sock_example.c
index 5546f8aac37e..6fc6e193ef1b 100644
--- a/samples/bpf/sock_example.c
+++ b/samples/bpf/sock_example.c
@@ -27,6 +27,7 @@
#include <linux/ip.h>
#include <stddef.h>
#include "libbpf.h"
+#include "sock_example.h"
char bpf_log_buf[BPF_LOG_BUF_SIZE];
diff --git a/samples/bpf/libbpf.c b/samples/bpf/sock_example.h
similarity index 92%
rename from samples/bpf/libbpf.c
rename to samples/bpf/sock_example.h
index bee473a494f1..09f7fe7e5fd7 100644
--- a/samples/bpf/libbpf.c
+++ b/samples/bpf/sock_example.h
@@ -1,4 +1,3 @@
-/* eBPF mini library */
#include <stdlib.h>
#include <stdio.h>
#include <linux/unistd.h>
@@ -11,7 +10,7 @@
#include <arpa/inet.h>
#include "libbpf.h"
-int open_raw_sock(const char *name)
+static inline int open_raw_sock(const char *name)
{
struct sockaddr_ll sll;
int sock;
diff --git a/samples/bpf/sockex1_user.c b/samples/bpf/sockex1_user.c
index 9454448bf198..6cd2feb3e9b3 100644
--- a/samples/bpf/sockex1_user.c
+++ b/samples/bpf/sockex1_user.c
@@ -3,6 +3,7 @@
#include <linux/bpf.h>
#include "libbpf.h"
#include "bpf_load.h"
+#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
diff --git a/samples/bpf/sockex2_user.c b/samples/bpf/sockex2_user.c
index 6a40600d5a83..0e0207c90841 100644
--- a/samples/bpf/sockex2_user.c
+++ b/samples/bpf/sockex2_user.c
@@ -3,6 +3,7 @@
#include <linux/bpf.h>
#include "libbpf.h"
#include "bpf_load.h"
+#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/resource.h>
diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c
index 9099c4255f23..b5524d417eb5 100644
--- a/samples/bpf/sockex3_user.c
+++ b/samples/bpf/sockex3_user.c
@@ -3,6 +3,7 @@
#include <linux/bpf.h>
#include "libbpf.h"
#include "bpf_load.h"
+#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/resource.h>
--
2.9.3
next prev parent reply other threads:[~2016-12-20 17:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 17:03 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 01/29] perf tools: Move headers check into bash script Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 02/29] perf sched timehist: Split is_idle_sample() Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 03/29] perf sched timehist: Introduce struct idle_time_data Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 04/29] perf sched timehist: Save callchain when entering idle Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 05/29] perf sched timehist: Skip non-idle events when necessary Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 06/29] perf sched timehist: Add -I/--idle-hist option Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 07/29] perf sched timehist: Show callchains for idle stat Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 08/29] perf tools: Remove some needless __maybe_unused Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 09/29] perf mem: Fix --all-user/--all-kernel options Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 10/29] perf evsel: Use variable instead of repeating lengthy FD macro Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 11/29] perf thread_map: Add thread_map__remove function Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 12/29] perf evsel: Allow to ignore missing pid Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 13/29] perf record: Force ignore_missing_thread for uid option Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 14/29] perf annotate: Support jump instruction with target as second operand Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 15/29] perf annotate: Fix jump target outside of function address range Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 16/29] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 17/29] tools lib bpf: use __u32 from linux/types.h Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 18/29] tools lib bpf: Add flags to bpf_create_map() Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 19/29] samples/bpf: Make samples more libbpf-centric Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 20/29] samples/bpf: Make perf_event_read() static Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 21/29] perf trace: Check if MAP_32BIT is defined (again) Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 22/29] perf bench futex: Fix lock-pi help string Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 23/29] perf annotate: Don't throw error for zero length symbols Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 24/29] perf diff: Do not overwrite valid build id Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 25/29] samples/bpf: Switch over to libbpf Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 26/29] tools lib bpf: Add bpf_prog_{attach,detach} Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 27/29] samples/bpf: Be consistent with bpf_load_program bpf_insn parameter Arnaldo Carvalho de Melo
2016-12-20 17:03 ` [PATCH 28/29] samples/bpf: Remove perf_event_open() declaration Arnaldo Carvalho de Melo
2016-12-20 17:03 ` Arnaldo Carvalho de Melo [this message]
2016-12-20 19:15 ` [GIT PULL 00/29] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161220170358.4350-30-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=joe@ovn.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).