aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-18 22:32:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-18 22:32:54 -0400
commit024ddc0ce1049298bd3cae60ae45d9c5f0fb8b9c (patch)
tree18b44ede17871ded93577c317f3afe3db122ba33 /samples
parent05df204549c510c7c56e58d25098c448998a0cd5 (diff)
parente56b8ce363a36fb7b74b80aaa5cc9084f2c908b4 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "Lots of fixes, here goes: 1) NULL deref in qtnfmac, from Gustavo A. R. Silva. 2) Kernel oops when fw download fails in rtlwifi, from Ping-Ke Shih. 3) Lost completion messages in AF_XDP, from Magnus Karlsson. 4) Correct bogus self-assignment in rhashtable, from Rishabh Bhatnagar. 5) Fix regression in ipv6 route append handling, from David Ahern. 6) Fix masking in __set_phy_supported(), from Heiner Kallweit. 7) Missing module owner set in x_tables icmp, from Florian Westphal. 8) liquidio's timeouts are HZ dependent, fix from Nicholas Mc Guire. 9) Link setting fixes for sh_eth and ravb, from Vladimir Zapolskiy. 10) Fix NULL deref when using chains in act_csum, from Davide Caratti. 11) XDP_REDIRECT needs to check if the interface is up and whether the MTU is sufficient. From Toshiaki Makita. 12) Net diag can do a double free when killing TCP_NEW_SYN_RECV connections, from Lorenzo Colitti. 13) nf_defrag in ipv6 can unnecessarily hold onto dst entries for a full minute, delaying device unregister. From Eric Dumazet. 14) Update MAC entries in the correct order in ixgbe, from Alexander Duyck. 15) Don't leave partial mangles bpf program in jit_subprogs, from Daniel Borkmann. 16) Fix pfmemalloc SKB state propagation, from Stefano Brivio. 17) Fix ACK handling in DCTCP congestion control, from Yuchung Cheng. 18) Use after free in tun XDP_TX, from Toshiaki Makita. 19) Stale ipv6 header pointer in ipv6 gre code, from Prashant Bhole. 20) Don't reuse remainder of RX page when XDP is set in mlx4, from Saeed Mahameed. 21) Fix window probe handling of TCP rapair sockets, from Stefan Baranoff. 22) Missing socket locking in smc_ioctl(), from Ursula Braun. 23) IPV6_ILA needs DST_CACHE, from Arnd Bergmann. 24) Spectre v1 fix in cxgb3, from Gustavo A. R. Silva. 25) Two spots in ipv6 do a rol32() on a hash value but ignore the result. Fixes from Colin Ian King" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (176 commits) tcp: identify cryptic messages as TCP seq # bugs ptp: fix missing break in switch hv_netvsc: Fix napi reschedule while receive completion is busy MAINTAINERS: Drop inactive Vitaly Bordug's email net: cavium: Add fine-granular dependencies on PCI net: qca_spi: Fix log level if probe fails net: qca_spi: Make sure the QCA7000 reset is triggered net: qca_spi: Avoid packet drop during initial sync ipv6: fix useless rol32 call on hash ipv6: sr: fix useless rol32 call on hash net: sched: Using NULL instead of plain integer net: usb: asix: replace mii_nway_restart in resume path net: cxgb3_main: fix potential Spectre v1 lib/rhashtable: consider param->min_size when setting initial table size net/smc: reset recv timeout after clc handshake net/smc: add error handling for get_user() net/smc: optimize consumer cursor updates net/nfc: Avoid stalls when nfc_alloc_send_skb() returned NULL. ipv6: ila: select CONFIG_DST_CACHE net: usb: rtl8150: demote allmulti message to dev_dbg() ...
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/.gitignore49
-rw-r--r--samples/bpf/parse_varlen.c6
-rw-r--r--samples/bpf/test_overhead_user.c19
-rw-r--r--samples/bpf/trace_event_user.c27
-rwxr-xr-xsamples/bpf/xdp2skb_meta.sh6
-rw-r--r--samples/bpf/xdpsock_user.c2
6 files changed, 93 insertions, 16 deletions
diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore
new file mode 100644
index 000000000000..8ae4940025f8
--- /dev/null
+++ b/samples/bpf/.gitignore
@@ -0,0 +1,49 @@
1cpustat
2fds_example
3lathist
4load_sock_ops
5lwt_len_hist
6map_perf_test
7offwaketime
8per_socket_stats_example
9sampleip
10sock_example
11sockex1
12sockex2
13sockex3
14spintest
15syscall_nrs.h
16syscall_tp
17task_fd_query
18tc_l2_redirect
19test_cgrp2_array_pin
20test_cgrp2_attach
21test_cgrp2_attach2
22test_cgrp2_sock
23test_cgrp2_sock2
24test_current_task_under_cgroup
25test_lru_dist
26test_map_in_map
27test_overhead
28test_probe_write_user
29trace_event
30trace_output
31tracex1
32tracex2
33tracex3
34tracex4
35tracex5
36tracex6
37tracex7
38xdp1
39xdp2
40xdp_adjust_tail
41xdp_fwd
42xdp_monitor
43xdp_redirect
44xdp_redirect_cpu
45xdp_redirect_map
46xdp_router_ipv4
47xdp_rxq_info
48xdp_tx_iptunnel
49xdpsock
diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index 95c16324760c..0b6f22feb2c9 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#define KBUILD_MODNAME "foo" 7#define KBUILD_MODNAME "foo"
8#include <linux/if_ether.h> 8#include <linux/if_ether.h>
9#include <linux/if_vlan.h>
9#include <linux/ip.h> 10#include <linux/ip.h>
10#include <linux/ipv6.h> 11#include <linux/ipv6.h>
11#include <linux/in.h> 12#include <linux/in.h>
@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end)
108 return 0; 109 return 0;
109} 110}
110 111
111struct vlan_hdr {
112 uint16_t h_vlan_TCI;
113 uint16_t h_vlan_encapsulated_proto;
114};
115
116SEC("varlen") 112SEC("varlen")
117int handle_ingress(struct __sk_buff *skb) 113int handle_ingress(struct __sk_buff *skb)
118{ 114{
diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
index 6caf47afa635..9d6dcaa9db92 100644
--- a/samples/bpf/test_overhead_user.c
+++ b/samples/bpf/test_overhead_user.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#define _GNU_SOURCE 7#define _GNU_SOURCE
8#include <sched.h> 8#include <sched.h>
9#include <errno.h>
9#include <stdio.h> 10#include <stdio.h>
10#include <sys/types.h> 11#include <sys/types.h>
11#include <asm/unistd.h> 12#include <asm/unistd.h>
@@ -44,8 +45,13 @@ static void test_task_rename(int cpu)
44 exit(1); 45 exit(1);
45 } 46 }
46 start_time = time_get_ns(); 47 start_time = time_get_ns();
47 for (i = 0; i < MAX_CNT; i++) 48 for (i = 0; i < MAX_CNT; i++) {
48 write(fd, buf, sizeof(buf)); 49 if (write(fd, buf, sizeof(buf)) < 0) {
50 printf("task rename failed: %s\n", strerror(errno));
51 close(fd);
52 return;
53 }
54 }
49 printf("task_rename:%d: %lld events per sec\n", 55 printf("task_rename:%d: %lld events per sec\n",
50 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time)); 56 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
51 close(fd); 57 close(fd);
@@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)
63 exit(1); 69 exit(1);
64 } 70 }
65 start_time = time_get_ns(); 71 start_time = time_get_ns();
66 for (i = 0; i < MAX_CNT; i++) 72 for (i = 0; i < MAX_CNT; i++) {
67 read(fd, buf, sizeof(buf)); 73 if (read(fd, buf, sizeof(buf)) < 0) {
74 printf("failed to read from /dev/urandom: %s\n", strerror(errno));
75 close(fd);
76 return;
77 }
78 }
68 printf("urandom_read:%d: %lld events per sec\n", 79 printf("urandom_read:%d: %lld events per sec\n",
69 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time)); 80 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
70 close(fd); 81 close(fd);
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index 1fa1becfa641..d08046ab81f0 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -122,6 +122,16 @@ static void print_stacks(void)
122 } 122 }
123} 123}
124 124
125static inline int generate_load(void)
126{
127 if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) {
128 printf("failed to generate some load with dd: %s\n", strerror(errno));
129 return -1;
130 }
131
132 return 0;
133}
134
125static void test_perf_event_all_cpu(struct perf_event_attr *attr) 135static void test_perf_event_all_cpu(struct perf_event_attr *attr)
126{ 136{
127 int nr_cpus = sysconf(_SC_NPROCESSORS_CONF); 137 int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
@@ -142,7 +152,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr)
142 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0); 152 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
143 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0); 153 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
144 } 154 }
145 system("dd if=/dev/zero of=/dev/null count=5000k status=none"); 155
156 if (generate_load() < 0) {
157 error = 1;
158 goto all_cpu_err;
159 }
146 print_stacks(); 160 print_stacks();
147all_cpu_err: 161all_cpu_err:
148 for (i--; i >= 0; i--) { 162 for (i--; i >= 0; i--) {
@@ -156,7 +170,7 @@ all_cpu_err:
156 170
157static void test_perf_event_task(struct perf_event_attr *attr) 171static void test_perf_event_task(struct perf_event_attr *attr)
158{ 172{
159 int pmu_fd; 173 int pmu_fd, error = 0;
160 174
161 /* per task perf event, enable inherit so the "dd ..." command can be traced properly. 175 /* per task perf event, enable inherit so the "dd ..." command can be traced properly.
162 * Enabling inherit will cause bpf_perf_prog_read_time helper failure. 176 * Enabling inherit will cause bpf_perf_prog_read_time helper failure.
@@ -171,10 +185,17 @@ static void test_perf_event_task(struct perf_event_attr *attr)
171 } 185 }
172 assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0); 186 assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
173 assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0); 187 assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
174 system("dd if=/dev/zero of=/dev/null count=5000k status=none"); 188
189 if (generate_load() < 0) {
190 error = 1;
191 goto err;
192 }
175 print_stacks(); 193 print_stacks();
194err:
176 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE); 195 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
177 close(pmu_fd); 196 close(pmu_fd);
197 if (error)
198 int_exit(0);