[PATCH] samples: bpf: fix: seg fault with NULL pointer arg

2018-12-01 Thread Daniel T. Lee
When NULL pointer accidentally passed to write_kprobe_events, due to strlen(NULL), segmentation fault happens. Changed code returns -1 to deal with this situation. Bug issued with Smatch, static analysis. Signed-off-by: Daniel T. Lee --- samples/bpf/bpf_load.c | 4 +++- 1 file changed, 3

[PATCH v2] samples: bpf: fix: seg fault with NULL pointer arg

2018-12-03 Thread Daniel T. Lee
When NULL pointer accidentally passed to write_kprobe_events, due to strlen(NULL), segmentation fault happens. Changed code returns -1 to deal with this situation. Bug issued with Smatch, static analysis. Signed-off-by: Daniel T. Lee --- samples/bpf/bpf_load.c | 4 +++- 1 file changed, 3

[PATCH] samples: bpf: fix: error handling regarding kprobe_events

2018-11-21 Thread Daniel T. Lee
t be verified whether from child ps or system. But using write() directly can verify the command failure, and it will treat all error as -1. So I suggest using write() directly to 'kprobe_events' rather than calling system(). Signed-off-by: Daniel T. Lee --- samples/bpf/bpf_load.c |

[PATCH v2] samples: bpf: fix: error handling regarding kprobe_events

2018-11-22 Thread Daniel T. Lee
t be verified whether from child ps or system. But using write() directly can verify the command failure, and it will treat all error as -1. So I suggest using write() directly to 'kprobe_events' rather than calling system(). Signed-off-by: Daniel T. Lee --- Changes in v2: -

[PATCH] tools: bpftool: add raw_tracepoint_writable prog type to header

2019-07-11 Thread Daniel T. Lee
ure'. This commit adds BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE entry to prog_type_name enum, and will eventually fixes the segfault issue. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpfto

[PATCH 0/2] tools: bpftool: add net (un)load command to load XDP

2019-07-30 Thread Daniel T. Lee
rt for XDP, through `net (un)load`, bpftool can further support other prog attach types. XDP (un)load tested on Netronome Agilio. Daniel T. Lee (2): tools: bpftool: add net load command to load XDP on interface tools: bpftool: add net unload command to unload XDP on interface tools/bpf/bpftool/

[PATCH 1/2] tools: bpftool: add net load command to load XDP on interface

2019-07-30 Thread Daniel T. Lee
k_xdp_fd'. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 107 +++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/net.c b/tools/bpf/bpftool/net.c index 67e99c56bc88..d3a4f18b5b95 100644 --- a/tools/bpf/bpftool/net.c

[PATCH 2/2] tools: bpftool: add net unload command to unload XDP on interface

2019-07-30 Thread Daniel T. Lee
By this commit, using `bpftool net unload`, the loaded XDP prog can be unloaded. Unloading the BPF prog will be done through libbpf 'bpf_set_link_xdp_fd' with the progfd set to -1. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 55 +++

Re: [PATCH 1/2] tools: bpftool: add net load command to load XDP on interface

2019-07-31 Thread Daniel T. Lee
On Wed, Jul 31, 2019 at 7:08 PM Jesper Dangaard Brouer wrote: > > On Wed, 31 Jul 2019 03:48:20 +0900 > "Daniel T. Lee" wrote: > > > By this commit, using `bpftool net load`, user can load XDP prog on > > interface. New type of enum 'net_load_type'

[v2,0/2] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-01 Thread Daniel T. Lee
this patch only contains support for XDP, through `net attach/detach`, bpftool can further support other prog attach types. XDP attach/detach tested on Mellanox ConnectX-4 and Netronome Agilio. --- Changes in v2: - command 'load/unload' changed to 'attach/detach' for the consis

[v2,1/2] tools: bpftool: add net attach command to attach XDP on interface

2019-08-01 Thread Daniel T. Lee
set_link_xdp_fd'. Signed-off-by: Daniel T. Lee --- Changes in v2: - command 'load' changed to 'attach' for the consistency - 'NET_ATTACH_TYPE_XDP_DRIVE' changed to 'NET_ATTACH_TYPE_XDP_DRIVER' tools/bpf/bpftool/net.c | 107 ++

[v2,2/2] tools: bpftool: add net detach command to detach XDP on interface

2019-08-01 Thread Daniel T. Lee
By this commit, using `bpftool net detach`, the attached XDP prog can be detached. Detaching the BPF prog will be done through libbpf 'bpf_set_link_xdp_fd' with the progfd set to -1. Signed-off-by: Daniel T. Lee --- Changes in v2: - command 'unload' changed to 'de

Re: [v2,1/2] tools: bpftool: add net attach command to attach XDP on interface

2019-08-01 Thread Daniel T. Lee
On Fri, Aug 2, 2019 at 8:36 AM Jakub Kicinski wrote: > > On Thu, 1 Aug 2019 17:11:32 +0900, Daniel T. Lee wrote: > > By this commit, using `bpftool net attach`, user can attach XDP prog on > > interface. New type of enum 'net_attach_type' has been made, as stated at &

Re: [v2,0/2] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-01 Thread Daniel T. Lee
Thank you for letting me know. I will add to next version of patch. And, thank you for the detailed review. :) On Fri, Aug 2, 2019 at 8:21 AM Jakub Kicinski wrote: > > On Thu, 1 Aug 2019 17:11:31 +0900, Daniel T. Lee wrote: > > Currently, bpftool net only supports dumping progs att

Re: [v2,2/2] tools: bpftool: add net detach command to detach XDP on interface

2019-08-02 Thread Daniel T. Lee
On Fri, Aug 2, 2019 at 3:26 PM Y Song wrote: > > On Thu, Aug 1, 2019 at 2:04 AM Daniel T. Lee wrote: > > > > By this commit, using `bpftool net detach`, the attached XDP prog can > > be detached. Detaching the BPF prog will be done through libbpf > > 'bpf_set_

Re: [v2,1/2] tools: bpftool: add net attach command to attach XDP on interface

2019-08-02 Thread Daniel T. Lee
On Fri, Aug 2, 2019 at 3:23 PM Y Song wrote: > > On Thu, Aug 1, 2019 at 2:04 AM Daniel T. Lee wrote: > > > > By this commit, using `bpftool net attach`, user can attach XDP prog on > > interface. New type of enum 'net_attach_type' has been made, as stated a

Re: [v2,1/2] tools: bpftool: add net attach command to attach XDP on interface

2019-08-03 Thread Daniel T. Lee
On Sat, Aug 3, 2019 at 3:39 AM Jakub Kicinski wrote: > > On Fri, 2 Aug 2019 14:02:29 +0900, Daniel T. Lee wrote: > > On Fri, Aug 2, 2019 at 8:36 AM Jakub Kicinski wrote: > > > On Thu, 1 Aug 2019 17:11:32 +0900, Daniel T. Lee wrote: > > > > By this commit, usi

[v3,3/4] tools: bpftool: add bash-completion for net attach/detach

2019-08-06 Thread Daniel T. Lee
This commit adds bash-completion for new "net attach/detach" subcommand for attaching XDP program on interface. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/bash-completion/bpftool | 64 +++ 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a

[v3,2/4] tools: bpftool: add net detach command to detach XDP on interface

2019-08-06 Thread Daniel T. Lee
By this commit, using `bpftool net detach`, the attached XDP prog can be detached. Detaching the BPF prog will be done through libbpf 'bpf_set_link_xdp_fd' with the progfd set to -1. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 42 +++

[v3,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-06 Thread Daniel T. Lee
attached XDP program could be replaced. Added new helper 'net_parse_dev' to parse the network device at argument. BPF prog will be attached through libbpf 'bpf_set_link_xdp_fd'. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 141 ---

[v3,0/4] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-06 Thread Daniel T. Lee
PE' comes first) - add 'dev' keyword in front of - added bash-completion and documentation Changes in v2: - command 'load/unload' changed to 'attach/detach' for the consistency Daniel T. Lee (4): tools: bpftool: add net attach command to attach XDP on int

[v3,4/4] tools: bpftool: add documentation for net attach/detach

2019-08-06 Thread Daniel T. Lee
Since, new sub-command 'net attach/detach' has been added for attaching XDP program on interface, this commit documents usage and sample output of `net attach/detach`. Signed-off-by: Daniel T. Lee --- .../bpf/bpftool/Documentation/bpftool-net.rst | 51 +-- 1 file c

[v4 2/4] samples: pktgen: fix proc_cmd command result check logic

2019-10-03 Thread Daniel T. Lee
his commit fixes this logic by grep-ing the "Result:" string only when the command is not for 'pg_ctrl'. For clarity of an execution flow, 'errexit' flag has been set. To cleanup pktgen on exit, trap has been added for EXIT signal. Signed-off-by: Daniel T. Lee ---

[v4 1/4] samples: pktgen: make variable consistent with option

2019-10-03 Thread Daniel T. Lee
existing variable name DST_MIN should be changed. Variable names are matched to the exact keyword used with pg_ctrl. Signed-off-by: Daniel T. Lee --- .../pktgen_bench_xmit_mode_netif_receive.sh | 8 .../pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 8 samples/pk

[v4 3/4] samples: pktgen: add helper functions for IP(v4/v6) CIDR parsing

2019-10-03 Thread Daniel T. Lee
This commit adds CIDR parsing and IP validate helper function to parse single IP or range of IP with CIDR. (e.g. 198.18.0.0/15) Validating the address should be preceded prior to the parsing. Helpers will be used in prior to set target address in samples/pktgen. Signed-off-by: Daniel T. Lee

[v4 4/4] samples: pktgen: allow to specify destination IP range (CIDR)

2019-10-03 Thread Daniel T. Lee
.3000: UDP, length 16 05:14:18.083366 IP6 fe80::99.107 > fe80::22.3000: UDP, length 16 05:14:18.083585 IP6 fe80::99.97 > fe80::21.3000: UDP, length 16 Signed-off-by: Daniel T. Lee --- Changes since v4: * 'validate_addr' is called prior to 'parse_addr' samples/

Re: [v4 1/4] samples: pktgen: make variable consistent with option

2019-10-04 Thread Daniel T. Lee
On Fri, Oct 4, 2019 at 9:52 PM Jesper Dangaard Brouer wrote: > > > On Fri, 4 Oct 2019 10:32:58 +0900 "Daniel T. Lee" > wrote: > > > [...] > Thanks for the review! > A general comment, you forgot a cover letter for your patchset. > At first, I thought

Re: [v4 1/4] samples: pktgen: make variable consistent with option

2019-10-04 Thread Daniel T. Lee
On Fri, Oct 4, 2019 at 10:41 PM Jesper Dangaard Brouer wrote: > > On Fri, 4 Oct 2019 22:28:26 +0900 > "Daniel T. Lee" wrote: > > > On Fri, Oct 4, 2019 at 9:52 PM Jesper Dangaard Brouer > > wrote: > > > > > > > > > On

Re: [v4 2/4] samples: pktgen: fix proc_cmd command result check logic

2019-10-04 Thread Daniel T. Lee
On Fri, Oct 4, 2019 at 10:24 PM Jesper Dangaard Brouer wrote: > > [...] > > Is this comment still relevant? You just excluded "pgctrl" from > getting into this section. > Oops, will fix it right away. > > +if [[ "$result" == "" ]]; then > > +grep "Result:" $proc_ctrl >&2 > > Mis

samples/bpf not working?

2019-10-04 Thread Daniel T. Lee
Currently, building the bpf samples isn't working. Running make from the directory 'samples/bpf' will just shows following result without compiling any samples. $ make make -C ../../ /git/linux/samples/bpf/ BPF_SAMPLES_PATH=/git/linux/samples/bpf make[1]: Entering directory '/git/linux' CALL

[PATCH net-next v5 0/4] samples: pktgen: allow to specify destination IP range

2019-10-05 Thread Daniel T. Lee
randomizing n-tuple. This patchset fixes the problem with checking the command result on proc_cmd, and add feature to allow destination IP range. Daniel T. Lee (4): samples: pktgen: make variable consistent with option samples: pktgen: fix proc_cmd command result check logic samples: pktgen: add

[PATCH net-next v5 2/4] samples: pktgen: fix proc_cmd command result check logic

2019-10-05 Thread Daniel T. Lee
#x27;. This commit fixes this logic by grep-ing the "Result:" string only when the command is not for 'pg_ctrl'. For clarity of an execution flow, 'errexit' flag has been set. To cleanup pktgen on exit, trap has been added for EXIT signal. Signed-off-by: Daniel T. Le

[PATCH net-next v5 1/4] samples: pktgen: make variable consistent with option

2019-10-05 Thread Daniel T. Lee
existing variable name DST_MIN should be changed. Variable names are matched to the exact keyword used with pg_ctrl. Signed-off-by: Daniel T. Lee --- .../pktgen_bench_xmit_mode_netif_receive.sh | 8 .../pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 8 samples/pk

[PATCH net-next v5 3/4] samples: pktgen: add helper functions for IP(v4/v6) CIDR parsing

2019-10-05 Thread Daniel T. Lee
This commit adds CIDR parsing and IP validate helper function to parse single IP or range of IP with CIDR. (e.g. 198.18.0.0/15) Validating the address should be preceded prior to the parsing. Helpers will be used in prior to set target address in samples/pktgen. Signed-off-by: Daniel T. Lee

[PATCH net-next v5 4/4] samples: pktgen: allow to specify destination IP range (CIDR)

2019-10-05 Thread Daniel T. Lee
.3000: UDP, length 16 05:14:18.083366 IP6 fe80::99.107 > fe80::22.3000: UDP, length 16 05:14:18.083585 IP6 fe80::99.97 > fe80::21.3000: UDP, length 16 Signed-off-by: Daniel T. Lee --- Changes since v4: * 'validate_addr' is called prior to 'parse_addr' samples/

[bpf-next v5] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-06 Thread Daniel T. Lee
ap_fd from '!= 0' to '< 0', since fd could be 0 when stdin is closed. Signed-off-by: Daniel T. Lee --- Changes in v5: - Change pcktsz map to static global variable Changes in v4: - make pckt_size no less than ICMP_TOOBIG_SIZE - Fix code style Changes in v2

Re: [bpf-next v5] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-07 Thread Daniel T. Lee
On Mon, Oct 7, 2019 at 12:37 PM Andrii Nakryiko wrote: > > On Sun, Oct 6, 2019 at 4:58 AM Daniel T. Lee wrote: > > > > Currently, at xdp_adjust_tail_kern.c, MAX_PCKT_SIZE is limited > > to 600. To make this size flexible, static global variable > > 'max_pcktsz

Re: [PATCH net-next v5 2/4] samples: pktgen: fix proc_cmd command result check logic

2019-10-07 Thread Daniel T. Lee
On Mon, Oct 7, 2019 at 5:15 PM Jesper Dangaard Brouer wrote: > > On Sat, 5 Oct 2019 17:25:07 +0900 > "Daniel T. Lee" wrote: > > > Currently, proc_cmd is used to dispatch command to 'pg_ctrl', 'pg_thread', > > 'pg_set'. proc_c

[PATCH bpf-next v6] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-07 Thread Daniel T. Lee
ap_fd from '!= 0' to '< 0', since fd could be 0 when stdin is closed. Signed-off-by: Daniel T. Lee --- Changes in v6: - Remove redundant error message Changes in v5: - Change pcktsz map to static global variable Changes in v4: - make pckt_size no less than ICMP_TOO

Re: [PATCH bpf-next v6] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-07 Thread Daniel T. Lee
On Tue, Oct 8, 2019 at 1:41 AM Andrii Nakryiko wrote: > > On Mon, Oct 7, 2019 at 9:06 AM Daniel T. Lee wrote: > > > > Currently, at xdp_adjust_tail_kern.c, MAX_PCKT_SIZE is limited > > to 600. To make this size flexible, static global variable > > 'max_pcktsz

[PATCH bpf-next v7] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-07 Thread Daniel T. Lee
er to fetch map from 'bpf_map__next' to 'bpf_object__find_map_fd_by_name'. Also, changed the way to test prog_fd, map_fd from '!= 0' to '< 0', since fd could be 0 when stdin is closed. Signed-off-by: Daniel T. Lee --- Changes in v6: - Remove redundant error

Re: [PATCH bpf-next v7] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-10-07 Thread Daniel T. Lee
On Tue, Oct 8, 2019 at 12:24 PM Alexei Starovoitov wrote: > > On Mon, Oct 7, 2019 at 10:21 AM Daniel T. Lee wrote: > > > > Currently, at xdp_adjust_tail_kern.c, MAX_PCKT_SIZE is limited > > to 600. To make this size flexible, static global variable > > 'max_pc

[PATCH] samples: bpf: make the use of xdp samples consistent

2019-06-24 Thread Daniel T. Lee
those two samples to fetch interface with it's name without changing the original index interface fetching. ( fetching in the same way as xdp_sample_pkts_user.c does.) Signed-off-by: Daniel T. Lee --- samples/bpf/xdp_adjust_tail_user.c | 12 ++-- samples/bpf/xdp_tx_iptunnel_u

Re: [PATCH] samples: bpf: make the use of xdp samples consistent

2019-06-24 Thread Daniel T. Lee
Will do right away! :) On Tue, Jun 25, 2019 at 3:24 AM Toke Høiland-Jørgensen wrote: > > "Daniel T. Lee" writes: > > > Currently, each xdp samples are inconsistent in the use. > > Most of the samples fetch the interface with it's name. > > (ex. xdp1, x

[PATCH v2] samples: bpf: make the use of xdp samples consistent

2019-06-24 Thread Daniel T. Lee
mples to fetch interface with it's name without changing the original index interface fetching. ( fetching in the same way as xdp_sample_pkts_user.c does.) Signed-off-by: Daniel T. Lee --- Changes in v2: - added xdp_redirect_user.c, xdp_redirect_map_user.c samples/bpf/xdp_adjust_tail_us

[PATCH v2] samples: bpf: make the use of xdp samples consistent

2019-06-24 Thread Daniel T. Lee
mples to fetch interface with it's name without changing the original index interface fetching. ( fetching in the same way as xdp_sample_pkts_user.c does.) Signed-off-by: Daniel T. Lee --- Changes in v2: - added xdp_redirect_user.c, xdp_redirect_map_user.c samples/bpf/xdp_adjust_tail_us

[PATCH 2/2] samples: pktgen: allow to specify destination port

2019-06-29 Thread Daniel T. Lee
script. -p : ($DST_PORT) destination PORT range (e.g. 433-444) is also allowed Signed-off-by: Daniel T. Lee --- samples/pktgen/README.rst| 1 + samples/pktgen/parameters.sh | 7 ++- .../pktgen/pktgen_bench_xmit_mode_netif_re

[PATCH 1/2] samples: pktgen: add some helper functions for port parsing

2019-06-29 Thread Daniel T. Lee
This commit adds port parsing and port validate helper function to parse single or range of port(s) from a given string. (e.g. 1234, 443-444) Helpers will be used in prior to set target port(s) in samples/pktgen. Signed-off-by: Daniel T. Lee --- samples/pktgen/functions.sh | 34

Re: [PATCH 2/2] samples: pktgen: allow to specify destination port

2019-07-01 Thread Daniel T. Lee
9 22:33:58 +0900 > "Daniel T. Lee" wrote: > > > Currently, kernel pktgen has the feature to specify udp destination port > > for sending packet. (e.g. pgset "udp_dst_min 9") > > > > But on samples, each of the scripts doesn't have any option to ac

[PATCH bpf-next 1/3] samples: bpf: Refactor xdp_monitor with libbpf

2020-10-09 Thread Daniel T. Lee
ff-by: Daniel T. Lee --- samples/bpf/Makefile | 2 +- samples/bpf/xdp_monitor_user.c | 144 - 2 files changed, 108 insertions(+), 38 deletions(-) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 4f1ed0e3cf9f..0cee2aa8970f 100644 --- a/sample

[PATCH bpf-next 0/3] samples: bpf: Refactor XDP programs with libbpf

2020-10-09 Thread Daniel T. Lee
o BTF-defined map. Daniel T. Lee (3): samples: bpf: Refactor xdp_monitor with libbpf samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu samples: bpf: refactor XDP kern program maps with BTF-defined map samples/bpf/Makefile| 4 +- sample

[PATCH bpf-next 3/3] samples: bpf: refactor XDP kern program maps with BTF-defined map

2020-10-09 Thread Daniel T. Lee
, this commit removes the max_entries attribute at PERF_EVENT_ARRAY map type. The libbpf's bpf_object__create_map() will automatically set max_entries to the maximum configured number of CPUs on the host. Signed-off-by: Daniel T. Lee --- samples/bpf/xdp_monitor_kern.c

[PATCH bpf-next 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

2020-10-09 Thread Daniel T. Lee
ethod. In addition, this refactors the logic of setting the map FD to simplify the code. Also, the missing removal of bpf_load.o in Makefile has been fixed. Signed-off-by: Daniel T. Lee --- samples/bpf/Makefile| 2 +- samples/bpf/xdp_redirect_cpu_user.c | 138 +--

Re: [PATCH bpf-next 1/3] samples: bpf: Refactor xdp_monitor with libbpf

2020-10-10 Thread Daniel T. Lee
On Sat, Oct 10, 2020 at 3:17 AM Andrii Nakryiko wrote: > > On Fri, Oct 9, 2020 at 9:04 AM Daniel T. Lee wrote: > > > > To avoid confusion caused by the increasing fragmentation of the BPF > > Loader program, this commit would like to change to the libbpf loader > >

Re: [PATCH bpf-next 3/3] samples: bpf: refactor XDP kern program maps with BTF-defined map

2020-10-10 Thread Daniel T. Lee
On Sat, Oct 10, 2020 at 3:25 AM Andrii Nakryiko wrote: > > On Fri, Oct 9, 2020 at 9:04 AM Daniel T. Lee wrote: > > > > Most of the samples were converted to use the new BTF-defined MAP as > > they moved to libbpf, but some of the samples were missing. > > > &g

[PATCH bpf-next v2 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

2020-10-10 Thread Daniel T. Lee
ethod. In addition, this refactors the logic of setting the map FD to simplify the code. Also, the missing removal of bpf_load.o in Makefile has been fixed. Signed-off-by: Daniel T. Lee --- Changes in v2: - program section match with bpf_program__is_ instead of strncmp - refactor pointer ar

[PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf

2020-10-10 Thread Daniel T. Lee
inter array initialization - error code cleanup Daniel T. Lee (3): samples: bpf: Refactor xdp_monitor with libbpf samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu samples: bpf: refactor XDP kern program maps with BTF-defined map samples/bpf/Mak

[PATCH bpf-next v2 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

2020-10-10 Thread Daniel T. Lee
ethod. In addition, this refactors the logic of setting the map FD to simplify the code. Also, the missing removal of bpf_load.o in Makefile has been fixed. Signed-off-by: Daniel T. Lee --- Changes in v2: - program section match with bpf_program__is_ instead of strncmp - refactor pointer ar

Re: [PATCH bpf-next 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

2020-10-10 Thread Daniel T. Lee
On Sat, Oct 10, 2020 at 3:23 AM Andrii Nakryiko wrote: > > On Fri, Oct 9, 2020 at 9:04 AM Daniel T. Lee wrote: > > > > From commit d7a18ea7e8b6 ("libbpf: Add generic bpf_program__attach()"), > > for some BPF programs, it is now possible to attach BPF progr

Re: [PATCH bpf-next 0/3] samples: bpf: Refactor XDP programs with libbpf

2020-10-10 Thread Daniel T. Lee
On Sat, Oct 10, 2020 at 3:30 AM Andrii Nakryiko wrote: > > On Fri, Oct 9, 2020 at 9:04 AM Daniel T. Lee wrote: > > > > To avoid confusion caused by the increasing fragmentation of the BPF > > Loader program, this commit would like to convert the previous bpf_load &g

[PATCH bpf-next v2 3/3] samples: bpf: refactor XDP kern program maps with BTF-defined map

2020-10-10 Thread Daniel T. Lee
, this commit removes the max_entries attribute at PERF_EVENT_ARRAY map type. The libbpf's bpf_object__create_map() will automatically set max_entries to the maximum configured number of CPUs on the host. Signed-off-by: Daniel T. Lee --- Changes in v2: - revert BTF key/val type to defau

[PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf

2020-10-10 Thread Daniel T. Lee
inter array initialization - error code cleanup Daniel T. Lee (3): samples: bpf: Refactor xdp_monitor with libbpf samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu samples: bpf: refactor XDP kern program maps with BTF-defined map samples/bpf/Mak

[PATCH bpf-next v2 1/3] samples: bpf: Refactor xdp_monitor with libbpf

2020-10-10 Thread Daniel T. Lee
ff-by: Daniel T. Lee --- Changes in v2: - added cleanup logic for bpf_link and bpf_object - split increment into seperate satement - refactor pointer array initialization samples/bpf/Makefile | 2 +- samples/bpf/xdp_monitor_user.c | 159 + 2 files changed

[PATCH bpf-next v2 3/3] samples: bpf: refactor XDP kern program maps with BTF-defined map

2020-10-10 Thread Daniel T. Lee
, this commit removes the max_entries attribute at PERF_EVENT_ARRAY map type. The libbpf's bpf_object__create_map() will automatically set max_entries to the maximum configured number of CPUs on the host. Signed-off-by: Daniel T. Lee --- Changes in v2: - revert BTF key/val type to defau

[PATCH bpf-next v2 1/3] samples: bpf: Refactor xdp_monitor with libbpf

2020-10-10 Thread Daniel T. Lee
ff-by: Daniel T. Lee --- Changes in v2: - added cleanup logic for bpf_link and bpf_object - split increment into seperate satement - refactor pointer array initialization samples/bpf/Makefile | 2 +- samples/bpf/xdp_monitor_user.c | 159 + 2 files changed

[PATCH 1/3] samples: bpf: fix bpf programs with kprobe/sys_connect event

2020-06-26 Thread Daniel T. Lee
sys_connect event by specifying the __sys_connect directly and this will bypass the "__x64_" appending rule of bpf_load. Fixes: 34745aed515c ("samples/bpf: fix kprobe attachment issue on x64") Signed-off-by: Daniel T. Lee --- samples/bpf/map_perf_test_kern.c

[PATCH 3/3] samples: bpf: refactor BPF map in map test with libbpf

2020-06-26 Thread Daniel T. Lee
directive. __array(values, struct inner_map) This commit refactors map in map test program with libbpf by explicitly defining inner map with BTF-defined format. Signed-off-by: Daniel T. Lee --- samples/bpf/Makefile | 2 +- samples/bpf/test_map_in_map_kern.c | 85 +++-

[PATCH 2/3] samples: bpf: cleanup pointer error check with libbpf

2020-06-26 Thread Daniel T. Lee
Libbpf has its own helper function to check for errors in the bpf data structure (pointer). And Some codes do not use this libbbpf helper function and check the pointer's error directly. This commit clean up the existing pointer error check logic with libbpf. Signed-off-by: Daniel T

Re: [PATCH bpf-next v2 1/7] samples: bpf: refactor hbm program with libbpf

2020-11-24 Thread Daniel T. Lee
Sorry for the late reply. On Sat, Nov 21, 2020 at 11:34 AM Martin KaFai Lau wrote: > > On Thu, Nov 19, 2020 at 03:06:11PM +, Daniel T. Lee wrote: > [ ... ] > > > static int run_bpf_prog(char *prog, int cg_id) > > [ ... ] > > if (!o

[PATCH bpf-next v3 0/7] bpf: remove bpf_load loader completely

2020-11-24 Thread Daniel T. Lee
d variable - change to destroy link even after link__pin() - fix return error code on exit - merge commit with changing Makefile Changes in v3: - cleanup bpf_link, bpf_object and cgroup fd both on success and error Daniel T. Lee (7): samples: bpf: refactor hbm program with libbpf samples: bpf

[PATCH bpf-next v3 2/7] samples: bpf: refactor test_cgrp2_sock2 program with libbpf

2020-11-24 Thread Daniel T. Lee
oblem that shell script cannot find the binary object from the current path, relative path './' has been added in front of binary. Fixes: 554ae6e792ef3 ("samples/bpf: add userspace example for prohibiting sockets") Signed-off-by: Daniel T. Lee --- Changes in v2: - cha

[PATCH bpf-next v3 5/7] samples: bpf: refactor test_overhead program with libbpf

2020-11-24 Thread Daniel T. Lee
code, this commit uses the number of available cpus with _SC_NPROCESSORS_ONLN. Signed-off-by: Daniel T. Lee Acked-by: Andrii Nakryiko --- Changes in v2: - add static at global variable and drop {} samples/bpf/Makefile | 2 +- samples/bpf/test_overhead_user.c | 82

[PATCH bpf-next v3 4/7] samples: bpf: refactor ibumad program with libbpf

2020-11-24 Thread Daniel T. Lee
not used on this program. Signed-off-by: Daniel T. Lee --- Changes in v2: - add static at global variable and drop {} - fix return error code on exit samples/bpf/Makefile | 2 +- samples/bpf/ibumad_kern.c | 26 +++--- samples/bpf/ibumad_user.c | 71

[PATCH bpf-next v3 6/7] samples: bpf: fix lwt_len_hist reusing previous BPF map

2020-11-24 Thread Daniel T. Lee
his commit add the executable permission to shell script files. Fixes: f74599f7c5309 ("bpf: Add tests and samples for LWT-BPF") Signed-off-by: Daniel T. Lee --- samples/bpf/lwt_len_hist.sh | 2 ++ samples/bpf/test_lwt_bpf.sh | 0 2 files changed, 2 insertions(+) mode change 100644 =

[PATCH bpf-next v3 3/7] samples: bpf: refactor task_fd_query program with libbpf

2020-11-24 Thread Daniel T. Lee
probe events, O_TRUNC flag has been used to clear 'uprobe_events' interface. Signed-off-by: Daniel T. Lee --- Changes in v2: - add static at global variable and drop {} - fix return error code on exit - restore DEBUGFS macro to absolute string path samples/bpf/Makefile

[PATCH bpf-next v3 7/7] samples: bpf: remove bpf_load loader completely

2020-11-24 Thread Daniel T. Lee
with the latest kernel BPF and causes confusion. Also, this commit removes the unused trace_helper and bpf_load from samples/bpf target objects from Makefile. Signed-off-by: Daniel T. Lee Acked-by: Jesper Dangaard Brouer Acked-by: Andrii Nakryiko --- Changes in v2: - merge commit with changing

[PATCH bpf-next v3 1/7] samples: bpf: refactor hbm program with libbpf

2020-11-24 Thread Daniel T. Lee
of BPF MAP definition. But this commit solves the problem by fixing this from 'queue_stats' map struct hvm_queue_stats -> hbm_queue_stats. Fixes: 36b5d471135c ("selftests/bpf: samples/bpf: Split off legacy stuff from bpf_helpers.h") Signed-off-by: Daniel T. L

Re: [v3,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-08 Thread Daniel T. Lee
On Thu, Aug 8, 2019 at 5:42 AM Jakub Kicinski wrote: > > On Wed, 7 Aug 2019 11:25:06 +0900, Daniel T. Lee wrote: > > By this commit, using `bpftool net attach`, user can attach XDP prog on > > interface. New type of enum 'net_attach_type' has been made, as stated at &

Re: [v3,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-08 Thread Daniel T. Lee
On Fri, Aug 9, 2019 at 2:50 AM Jakub Kicinski wrote: > > On Thu, 8 Aug 2019 07:15:22 +0900, Daniel T. Lee wrote: > > > > + return -EINVAL; > > > > + } > > > > + > > > > + NEXT_ARG(); > > > > > > nit: the n

Re: [v3,3/4] tools: bpftool: add bash-completion for net attach/detach

2019-08-08 Thread Daniel T. Lee
On Fri, Aug 9, 2019 at 1:48 AM Quentin Monnet wrote: > > 2019-08-07 11:25 UTC+0900 ~ Daniel T. Lee > > This commit adds bash-completion for new "net attach/detach" > > subcommand for attaching XDP program on interface. > > > > Signed-off-by: Daniel T.

Re: [v3,4/4] tools: bpftool: add documentation for net attach/detach

2019-08-08 Thread Daniel T. Lee
On Fri, Aug 9, 2019 at 1:48 AM Quentin Monnet wrote: > > 2019-08-07 11:25 UTC+0900 ~ Daniel T. Lee > > Since, new sub-command 'net attach/detach' has been added for > > attaching XDP program on interface, > > this commit documents usage and sample output of `

[v4,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-09 Thread Daniel T. Lee
attached XDP program could be replaced. Added new helper 'net_parse_dev' to parse the network device at argument. BPF prog will be attached through libbpf 'bpf_set_link_xdp_fd'. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 136 +-

[v4,0/4] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-09 Thread Daniel T. Lee
#x27; changed to 'attach/detach' for the consistency Daniel T. Lee (4): tools: bpftool: add net attach command to attach XDP on interface tools: bpftool: add net detach command to detach XDP on interface tools: bpftool: add bash-completion for net attach/detach tools: bpftool: add doc

[v4,3/4] tools: bpftool: add bash-completion for net attach/detach

2019-08-09 Thread Daniel T. Lee
This commit adds bash-completion for new "net attach/detach" subcommand for attaching XDP program on interface. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/bash-completion/bpftool | 65 +++ 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a

[v4,4/4] tools: bpftool: add documentation for net attach/detach

2019-08-09 Thread Daniel T. Lee
Since, new sub-command 'net attach/detach' has been added for attaching XDP program on interface, this commit documents usage and sample output of `net attach/detach`. Signed-off-by: Daniel T. Lee --- .../bpf/bpftool/Documentation/bpftool-net.rst | 57 ++- 1 file c

[v4,2/4] tools: bpftool: add net detach command to detach XDP on interface

2019-08-09 Thread Daniel T. Lee
By this commit, using `bpftool net detach`, the attached XDP prog can be detached. Detaching the BPF prog will be done through libbpf 'bpf_set_link_xdp_fd' with the progfd set to -1. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 42 +++

Re: [v4,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-12 Thread Daniel T. Lee
On Mon, Aug 12, 2019 at 9:27 AM Y Song wrote: > > On Fri, Aug 9, 2019 at 6:35 AM Daniel T. Lee wrote: > > > > By this commit, using `bpftool net attach`, user can attach XDP prog on > > interface. New type of enum 'net_attach_type' has been made, as stated a

[v5,2/4] tools: bpftool: add net detach command to detach XDP on interface

2019-08-12 Thread Daniel T. Lee
By this commit, using `bpftool net detach`, the attached XDP prog can be detached. Detaching the BPF prog will be done through libbpf 'bpf_set_link_xdp_fd' with the progfd set to -1. Acked-by: Yonghong Song Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/

[v5,0/4] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-12 Thread Daniel T. Lee
h-completion and documentation Changes in v2: - command 'load/unload' changed to 'attach/detach' for the consistency Daniel T. Lee (4): tools: bpftool: add net attach command to attach XDP on interface tools: bpftool: add net detach command to detach XDP on interface

[v5,3/4] tools: bpftool: add bash-completion for net attach/detach

2019-08-12 Thread Daniel T. Lee
This commit adds bash-completion for new "net attach/detach" subcommand for attaching XDP program on interface. Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/bash-completion/bpftool | 65 +++ 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a

[v5,4/4] tools: bpftool: add documentation for net attach/detach

2019-08-12 Thread Daniel T. Lee
Since, new sub-command 'net attach/detach' has been added for attaching XDP program on interface, this commit documents usage and sample output of `net attach/detach`. Signed-off-by: Daniel T. Lee --- .../bpf/bpftool/Documentation/bpftool-net.rst | 57 ++- 1 file c

[v5,1/4] tools: bpftool: add net attach command to attach XDP on interface

2019-08-12 Thread Daniel T. Lee
attached XDP program could be replaced. Added new helper 'net_parse_dev' to parse the network device at argument. BPF prog will be attached through libbpf 'bpf_set_link_xdp_fd'. Acked-by: Yonghong Song Signed-off-by: Daniel T. Lee --- tools/bpf/bpftool/net.c | 136 +++

Re: [v5,0/4] tools: bpftool: add net attach/detach command to attach XDP prog

2019-08-14 Thread Daniel T. Lee
On Wed, Aug 14, 2019 at 6:43 AM Jakub Kicinski wrote: > > On Tue, 13 Aug 2019 11:46:17 +0900, Daniel T. Lee wrote: > > Currently, bpftool net only supports dumping progs attached on the > > interface. To attach XDP prog on interface, user must use other tool > > (eg.

[PATCH] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-08-26 Thread Daniel T. Lee
is used, the size of maximum packet will be 600 as a default. Signed-off-by: Daniel T. Lee --- samples/bpf/xdp_adjust_tail_kern.c | 23 +++ samples/bpf/xdp_adjust_tail_user.c | 21 +++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff

[bpf-next, v2] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-08-26 Thread Daniel T. Lee
is used, the size of maximum packet will be 600 as a default. Signed-off-by: Daniel T. Lee --- Changes in v2: - Change the helper to fetch map from 'bpf_map__next' to 'bpf_object__find_map_fd_by_name'. samples/bpf/xdp_adjust_tail_kern.c | 23 +++

Re: [PATCH] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-08-26 Thread Daniel T. Lee
On Tue, Aug 27, 2019 at 12:54 AM Maciej Fijalkowski wrote: > > On Mon, 26 Aug 2019 18:57:22 +0900 > "Daniel T. Lee" wrote: > > > Currently, at xdp_adjust_tail_kern.c, MAX_PCKT_SIZE is limited > > to 600. To make this size flexible, a new map 'pcktsz' i

[PATCH 3/3] samples: pktgen: allow to specify destination IP range (CIDR)

2019-08-28 Thread Daniel T. Lee
, length 16 05:14:18.083366 IP6 fe80::99.107 > fe80::22.3000: UDP, length 16 05:14:18.083585 IP6 fe80::99.97 > fe80::21.3000: UDP, length 16 Signed-off-by: Daniel T. Lee --- samples/pktgen/README.rst | 2 +- samples/pktgen/parameters.sh

[PATCH 1/3] samples: pktgen: make variable consistent with option

2019-08-28 Thread Daniel T. Lee
existing variable name DST_MIN should be changed. Variable names are matched to the exact keyword used with pg_ctrl. Signed-off-by: Daniel T. Lee --- .../pktgen_bench_xmit_mode_netif_receive.sh | 8 .../pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 8 samples/pk

[PATCH 2/3] samples: pktgen: add helper functions for IP(v4/v6) CIDR parsing

2019-08-28 Thread Daniel T. Lee
This commit adds CIDR parsing and IP validate helper function to parse single IP or range of IP with CIDR. (e.g. 198.18.0.0/15) Helpers will be used in prior to set target address in samples/pktgen. Signed-off-by: Daniel T. Lee --- samples/pktgen/functions.sh | 134

Re: [bpf-next, v2] samples: bpf: add max_pckt_size option at xdp_adjust_tail

2019-08-29 Thread Daniel T. Lee
On Fri, Aug 30, 2019 at 5:42 AM Song Liu wrote: > > On Mon, Aug 26, 2019 at 9:52 AM Daniel T. Lee wrote: > > > > Currently, at xdp_adjust_tail_kern.c, MAX_PCKT_SIZE is limited > > to 600. To make this size flexible, a new map 'pcktsz' is added. > > >

  1   2   3   >