]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
samples/bpf: Move open_raw_sock to separate header
authorJoe Stringer <joe@ovn.org>
Fri, 9 Dec 2016 02:46:20 +0000 (18:46 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Dec 2016 15:00:40 +0000 (12:00 -0300)
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
samples/bpf/fds_example.c
samples/bpf/libbpf.h
samples/bpf/sock_example.c
samples/bpf/sock_example.h [moved from samples/bpf/libbpf.c with 92% similarity]
samples/bpf/sockex1_user.c
samples/bpf/sockex2_user.c
samples/bpf/sockex3_user.c

index 5a73f5a7ace1a054ce7f7dafa5369322031336e5..f01b66f277b0b33e5874b7e3bca4b9d895fced9a 100644 (file)
@@ -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)
index a5cddc99cccdea8165ff567adea7c2fdc31dcc12..e29bd52ff9e85c6dd6a2996bd213567e51e0328e 100644 (file)
@@ -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)
index 09aedc320009db23e8800145b8518da9b0e5ce77..3705fba453a005fb32f5dfb51dd5763f5f364ccf 100644 (file)
@@ -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
index 5546f8aac37e627a40bd7774e0b9edfb1bc4358e..6fc6e193ef1b12ecbb13f5c7729552306632708b 100644 (file)
@@ -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];
 
similarity index 92%
rename from samples/bpf/libbpf.c
rename to samples/bpf/sock_example.h
index bee473a494f1767ce2ddf0361af8b675dacd632d..09f7fe7e5fd74c289586711263d99bd9e25b1c2c 100644 (file)
@@ -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;
index 9454448bf198504de53d1883c664a1067385b784..6cd2feb3e9b364aa4ec75c538fe954e581fbd84e 100644 (file)
@@ -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>
 
index 6a40600d5a838952dc0f56e987c32bdad5bb3047..0e0207c9084130c362b600f6b8cd453d2541c4dc 100644 (file)
@@ -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>
index 9099c4255f23919d6a988ec7982c3e36d6d66de5..b5524d417eb57acd808aa07f4e876191df734166 100644 (file)
@@ -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>