aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-06 17:45:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-06 17:45:08 -0400
commitaae3dbb4776e7916b6cd442d00159bea27a695c1 (patch)
treed074c5d783a81e7e2e084b1eba77f57459da7e37 /tools/lib
parentec3604c7a5aae8953545b0d05495357009a960e5 (diff)
parent66bed8465a808400eb14562510e26c8818082cb8 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: 1) Support ipv6 checksum offload in sunvnet driver, from Shannon Nelson. 2) Move to RB-tree instead of custom AVL code in inetpeer, from Eric Dumazet. 3) Allow generic XDP to work on virtual devices, from John Fastabend. 4) Add bpf device maps and XDP_REDIRECT, which can be used to build arbitrary switching frameworks using XDP. From John Fastabend. 5) Remove UFO offloads from the tree, gave us little other than bugs. 6) Remove the IPSEC flow cache, from Florian Westphal. 7) Support ipv6 route offload in mlxsw driver. 8) Support VF representors in bnxt_en, from Sathya Perla. 9) Add support for forward error correction modes to ethtool, from Vidya Sagar Ravipati. 10) Add time filter for packet scheduler action dumping, from Jamal Hadi Salim. 11) Extend the zerocopy sendmsg() used by virtio and tap to regular sockets via MSG_ZEROCOPY. From Willem de Bruijn. 12) Significantly rework value tracking in the BPF verifier, from Edward Cree. 13) Add new jump instructions to eBPF, from Daniel Borkmann. 14) Rework rtnetlink plumbing so that operations can be run without taking the RTNL semaphore. From Florian Westphal. 15) Support XDP in tap driver, from Jason Wang. 16) Add 32-bit eBPF JIT for ARM, from Shubham Bansal. 17) Add Huawei hinic ethernet driver. 18) Allow to report MD5 keys in TCP inet_diag dumps, from Ivan Delalande. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1780 commits) i40e: point wb_desc at the nvm_wb_desc during i40e_read_nvm_aq i40e: avoid NVM acquire deadlock during NVM update drivers: net: xgene: Remove return statement from void function drivers: net: xgene: Configure tx/rx delay for ACPI drivers: net: xgene: Read tx/rx delay for ACPI rocker: fix kcalloc parameter order rds: Fix non-atomic operation on shared flag variable net: sched: don't use GFP_KERNEL under spin lock vhost_net: correctly check tx avail during rx busy polling net: mdio-mux: add mdio_mux parameter to mdio_mux_init() rxrpc: Make service connection lookup always check for retry net: stmmac: Delete dead code for MDIO registration gianfar: Fix Tx flow control deactivation cxgb4: Ignore MPS_TX_INT_CAUSE[Bubble] for T6 cxgb4: Fix pause frame count in t4_get_port_stats cxgb4: fix memory leak tun: rename generic_xdp to skb_xdp tun: reserve extra headroom only when XDP is set net: dsa: bcm_sf2: Configure IMP port TC2QOS mapping net: dsa: bcm_sf2: Advertise number of egress queues ...
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/bpf/Makefile4
-rw-r--r--tools/lib/bpf/bpf.c32
-rw-r--r--tools/lib/bpf/bpf.h6
-rw-r--r--tools/lib/bpf/libbpf.c29
-rw-r--r--tools/lib/bpf/libbpf.h2
5 files changed, 69 insertions, 4 deletions
diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 4ed0257dc1f3..d2441db34740 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -189,6 +189,10 @@ install_lib: all_cmd
189 $(call QUIET_INSTALL, $(LIB_FILE)) \ 189 $(call QUIET_INSTALL, $(LIB_FILE)) \
190 $(call do_install,$(LIB_FILE),$(libdir_SQ)) 190 $(call do_install,$(LIB_FILE),$(libdir_SQ))
191 191
192install_headers:
193 $(call QUIET_INSTALL, headers) \
194 $(call do_install,bpf.h,$(prefix)/include/bpf,644)
195
192install: install_lib 196install: install_lib
193 197
194### Cleaning rules 198### Cleaning rules
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index e5bbb090bf88..1d6907d379c9 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -57,8 +57,9 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
57 return syscall(__NR_bpf, cmd, attr, size); 57 return syscall(__NR_bpf, cmd, attr, size);
58} 58}
59 59
60int bpf_create_map(enum bpf_map_type map_type, int key_size, 60int bpf_create_map_node(enum bpf_map_type map_type, int key_size,
61 int value_size, int max_entries, __u32 map_flags) 61 int value_size, int max_entries, __u32 map_flags,
62 int node)
62{ 63{
63 union bpf_attr attr; 64 union bpf_attr attr;
64 65
@@ -69,12 +70,24 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size,
69 attr.value_size = value_size; 70 attr.value_size = value_size;
70 attr.max_entries = max_entries; 71 attr.max_entries = max_entries;
71 attr.map_flags = map_flags; 72 attr.map_flags = map_flags;
73 if (node >= 0) {
74 attr.map_flags |= BPF_F_NUMA_NODE;
75 attr.numa_node = node;
76 }
72 77
73 return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); 78 return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
74} 79}
75 80
76int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size, 81int bpf_create_map(enum bpf_map_type map_type, int key_size,
77 int inner_map_fd, int max_entries, __u32 map_flags) 82 int value_size, int max_entries, __u32 map_flags)
83{
84 return bpf_create_map_node(map_type, key_size, value_size,
85 max_entries, map_flags, -1);
86}
87
88int bpf_create_map_in_map_node(enum bpf_map_type map_type, int key_size,
89 int inner_map_fd, int max_entries,
90 __u32 map_flags, int node)
78{ 91{
79 union bpf_attr attr; 92 union bpf_attr attr;
80 93
@@ -86,10 +99,21 @@ int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size,
86 attr.inner_map_fd = inner_map_fd; 99 attr.inner_map_fd = inner_map_fd;
87 attr.max_entries = max_entries; 100 attr.max_entries = max_entries;
88 attr.map_flags = map_flags; 101 attr.map_flags = map_flags;
102 if (node >= 0) {
103 attr.map_flags |= BPF_F_NUMA_NODE;
104 attr.numa_node = node;
105 }
89 106
90 return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); 107 return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
91} 108}
92 109
110int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size,
111 int inner_map_fd, int max_entries, __u32 map_flags)
112{
113 return bpf_create_map_in_map_node(map_type, key_size, inner_map_fd,
114 max_entries, map_flags, -1);
115}
116
93int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, 117int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
94 size_t insns_cnt, const char *license, 118 size_t insns_cnt, const char *license,
95 __u32 kern_version, char *log_buf, size_t log_buf_sz) 119 __u32 kern_version, char *log_buf, size_t log_buf_sz)
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 418c86e69bcb..b8ea5843c39e 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -24,8 +24,14 @@
24#include <linux/bpf.h> 24#include <linux/bpf.h>
25#include <stddef.h> 25#include <stddef.h>
26 26
27int bpf_create_map_node(enum bpf_map_type map_type, int key_size,
28 int value_size, int max_entries, __u32 map_flags,
29 int node);
27int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size, 30int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
28 int max_entries, __u32 map_flags); 31 int max_entries, __u32 map_flags);
32int bpf_create_map_in_map_node(enum bpf_map_type map_type, int key_size,
33 int inner_map_fd, int max_entries,
34 __u32 map_flags, int node);
29int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size, 35int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size,
30 int inner_map_fd, int max_entries, __u32 map_flags); 36 int inner_map_fd, int max_entries, __u32 map_flags);
31 37
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 8c67a90dbd82..35f6dfcdc565 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1745,3 +1745,32 @@ long libbpf_get_error(const void *ptr)
1745 return PTR_ERR(ptr); 1745 return PTR_ERR(ptr);
1746 return 0; 1746 return 0;
1747} 1747}
1748
1749int bpf_prog_load(const char *file, enum bpf_prog_type type,
1750 struct bpf_object **pobj, int *prog_fd)
1751{
1752 struct bpf_program *prog;
1753 struct bpf_object *obj;
1754 int err;
1755
1756 obj = bpf_object__open(file);
1757 if (IS_ERR(obj))
1758 return -ENOENT;
1759
1760 prog = bpf_program__next(NULL, obj);
1761 if (!prog) {
1762 bpf_object__close(obj);
1763 return -ENOENT;
1764 }
1765
1766 bpf_program__set_type(prog, type);
1767 err = bpf_object__load(obj);
1768 if (err) {
1769 bpf_object__close(obj);
1770 return -EINVAL;
1771 }
1772
1773 *pobj = obj;
1774 *prog_fd = bpf_program__fd(prog);
1775 return 0;
1776}
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 32c7252f734e..7959086eb9c9 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -243,4 +243,6 @@ int bpf_map__pin(struct bpf_map *map, const char *path);
243 243
244long libbpf_get_error(const void *ptr); 244long libbpf_get_error(const void *ptr);
245 245
246int bpf_prog_load(const char *file, enum bpf_prog_type type,
247 struct bpf_object **pobj, int *prog_fd);
246#endif 248#endif