Skip to content

Commit

Permalink
samples/bpf: Move open_raw_sock to separate header
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Stringer authored and Arnaldo Carvalho de Melo committed Dec 20, 2016
1 parent 205c8ad commit 9899694
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion samples/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions samples/bpf/fds_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions samples/bpf/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions samples/bpf/sock_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
3 changes: 1 addition & 2 deletions samples/bpf/libbpf.c → samples/bpf/sock_example.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eBPF mini library */
#include <stdlib.h>
#include <stdio.h>
#include <linux/unistd.h>
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions samples/bpf/sockex1_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions samples/bpf/sockex2_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions samples/bpf/sockex3_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 9899694

Please sign in to comment.