From: David Wang <00107082@163.com>
To: fw@strlen.de
Cc: 00107082@163.com, andrii@kernel.org, ast@kernel.org,
bpf@vger.kernel.org, daniel@iogearbox.net, haoluo@google.com,
john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org,
linux-kernel@vger.kernel.org, martin.lau@linux.dev,
sdf@google.com, song@kernel.org, yonghong.song@linux.dev
Subject:
Date: Mon, 4 Sep 2023 19:29:22 +0800 [thread overview]
Message-ID: <20230904112922.13882-1-00107082@163.com> (raw)
In-Reply-To: <20230904104856.GE11802@breakpoint.cc>
At 2023-09-04 18:48:56, "Florian Westphal" <fw@strlen.de> wrote:
>David Wang <00107082@163.com> wrote:
>> This sample code implements a simple ipv4
>> blacklist via the new bpf type BPF_PROG_TYPE_NETFILTER,
>> which was introduced in 6.4.
>>
>> The bpf program drops package if destination ip address
>> hits a match in the map of type BPF_MAP_TYPE_LPM_TRIE,
>>
>> The userspace code would load the bpf program,
>> attach it to netfilter's FORWARD/OUTPUT hook,
>> and then write ip patterns into the bpf map.
>
>Thanks, I think its good to have this.
Thanks for the quick response! Glad to contribute!
>> +
>> +#define NF_DROP 0
>> +#define NF_ACCEPT 1
>
>If you are interested, you could send a patch for nf-next that
>makes the uapi headers expose this as enum, AFAIU that would make
>the verdict nanes available via vmlinux.h.
>
I think I can work on this.
>> + if (pvalue) {
>> + /* cat /sys/kernel/debug/tracing/trace_pipe */
>> + bpf_printk("rule matched with %d...\n", *pvalue);
>
>If you are interested you could send a patch that adds a kfunc to
>nf_bpf_link that exposes nf_log_packet() to bpf.
>
>nf_log_packet has a terrible api, I suggest to have the kfunc take
>'struct nf_hook_state *' instead of 6+ members of that struct as
>argument.
>
Package logging strategy is out of my league, for now, but I will keep eye on this.
David
next prev parent reply other threads:[~2023-09-04 11:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 10:21 [PATCH] samples/bpf: Add sample usage for BPF_PROG_TYPE_NETFILTER David Wang
2023-09-04 10:48 ` Florian Westphal
2023-09-04 11:10 ` David Wang
2023-09-04 11:29 ` David Wang [this message]
2023-09-04 21:01 ` Alexei Starovoitov
2023-09-05 3:16 ` David Wang
2023-09-05 8:41 ` Toke Høiland-Jørgensen
2023-09-05 10:52 ` David Wang
2023-09-05 11:09 ` David Wang
2023-09-05 15:49 ` Alexei Starovoitov
2023-09-05 16:06 ` David Wang
2023-09-05 9:05 ` Donald Hunter
2023-09-05 10:57 ` David Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230904112922.13882-1-00107082@163.com \
--to=00107082@163.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=fw@strlen.de \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox