* [PATCH] kcm: use BPF_PROG_RUN
@ 2019-09-05 21:15 Sami Tolvanen
2019-09-06 0:07 ` Yonghong Song
0 siblings, 1 reply; 6+ messages in thread
From: Sami Tolvanen @ 2019-09-05 21:15 UTC (permalink / raw)
To: David S. Miller, Tom Herbert; +Cc: netdev, bpf, linux-kernel, Sami Tolvanen
Instead of invoking struct bpf_prog::bpf_func directly, use the
BPF_PROG_RUN macro.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
net/kcm/kcmsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 5dbc0c48f8cb..f350c613bd7d 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -379,7 +379,7 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
struct bpf_prog *prog = psock->bpf_prog;
- return (*prog->bpf_func)(skb, prog->insnsi);
+ return BPF_PROG_RUN(prog, skb);
}
static int kcm_read_sock_done(struct strparser *strp, int err)
--
2.23.0.187.g17f5b7556c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kcm: use BPF_PROG_RUN
2019-09-05 21:15 [PATCH] kcm: use BPF_PROG_RUN Sami Tolvanen
@ 2019-09-06 0:07 ` Yonghong Song
2019-09-06 17:06 ` Alexei Starovoitov
0 siblings, 1 reply; 6+ messages in thread
From: Yonghong Song @ 2019-09-06 0:07 UTC (permalink / raw)
To: Sami Tolvanen, David S. Miller, Tom Herbert; +Cc: netdev, bpf, linux-kernel
On 9/5/19 2:15 PM, Sami Tolvanen wrote:
> Instead of invoking struct bpf_prog::bpf_func directly, use the
> BPF_PROG_RUN macro.
>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> net/kcm/kcmsock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index 5dbc0c48f8cb..f350c613bd7d 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -379,7 +379,7 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
> struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
> struct bpf_prog *prog = psock->bpf_prog;
>
> - return (*prog->bpf_func)(skb, prog->insnsi);
> + return BPF_PROG_RUN(prog, skb);
> }
>
> static int kcm_read_sock_done(struct strparser *strp, int err)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kcm: use BPF_PROG_RUN
2019-09-06 0:07 ` Yonghong Song
@ 2019-09-06 17:06 ` Alexei Starovoitov
2019-09-23 21:31 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2019-09-06 17:06 UTC (permalink / raw)
To: Yonghong Song
Cc: Sami Tolvanen, David S. Miller, Tom Herbert, netdev, bpf, linux-kernel
On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
> > Instead of invoking struct bpf_prog::bpf_func directly, use the
> > BPF_PROG_RUN macro.
> >
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>
> Acked-by: Yonghong Song <yhs@fb.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kcm: use BPF_PROG_RUN
2019-09-06 17:06 ` Alexei Starovoitov
@ 2019-09-23 21:31 ` Eric Dumazet
2019-09-24 18:59 ` Daniel Borkmann
0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2019-09-23 21:31 UTC (permalink / raw)
To: Alexei Starovoitov, Yonghong Song
Cc: Sami Tolvanen, David S. Miller, Tom Herbert, netdev, bpf, linux-kernel
On 9/6/19 10:06 AM, Alexei Starovoitov wrote:
> On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
>>
>>
>>
>> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
>>> Instead of invoking struct bpf_prog::bpf_func directly, use the
>>> BPF_PROG_RUN macro.
>>>
>>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>>
>> Acked-by: Yonghong Song <yhs@fb.com>
>
> Applied. Thanks
>
Then we probably need this as well, what do you think ?
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..6508e88efdaf57f206b84307f5ad5915a2ed21f7 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -378,8 +378,13 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
{
struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
struct bpf_prog *prog = psock->bpf_prog;
+ int res;
- return BPF_PROG_RUN(prog, skb);
+ preempt_disable();
+ res = BPF_PROG_RUN(prog, skb);
+ preempt_enable();
+
+ return res;
}
static int kcm_read_sock_done(struct strparser *strp, int err)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kcm: use BPF_PROG_RUN
2019-09-23 21:31 ` Eric Dumazet
@ 2019-09-24 18:59 ` Daniel Borkmann
2019-09-24 19:17 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2019-09-24 18:59 UTC (permalink / raw)
To: Eric Dumazet
Cc: Alexei Starovoitov, Yonghong Song, Sami Tolvanen,
David S. Miller, Tom Herbert, netdev, bpf, linux-kernel
On Mon, Sep 23, 2019 at 02:31:04PM -0700, Eric Dumazet wrote:
> On 9/6/19 10:06 AM, Alexei Starovoitov wrote:
> > On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
> >> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
> >>> Instead of invoking struct bpf_prog::bpf_func directly, use the
> >>> BPF_PROG_RUN macro.
> >>>
> >>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> >>
> >> Acked-by: Yonghong Song <yhs@fb.com>
> >
> > Applied. Thanks
>
> Then we probably need this as well, what do you think ?
Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption
disabled") probably forgot about it since it wasn't using BPF_PROG_RUN()
in the first place. If you get a chance, please send a proper patch,
thanks!
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index 8f12f5c6ab875ebaa6c59c6268c337919fb43bb9..6508e88efdaf57f206b84307f5ad5915a2ed21f7 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -378,8 +378,13 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
> {
> struct kcm_psock *psock = container_of(strp, struct kcm_psock, strp);
> struct bpf_prog *prog = psock->bpf_prog;
> + int res;
>
> - return BPF_PROG_RUN(prog, skb);
> + preempt_disable();
> + res = BPF_PROG_RUN(prog, skb);
> + preempt_enable();
> +
> + return res;
> }
>
> static int kcm_read_sock_done(struct strparser *strp, int err)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kcm: use BPF_PROG_RUN
2019-09-24 18:59 ` Daniel Borkmann
@ 2019-09-24 19:17 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2019-09-24 19:17 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Alexei Starovoitov, Yonghong Song, Sami Tolvanen,
David S. Miller, Tom Herbert, netdev, bpf, linux-kernel
On 9/24/19 11:59 AM, Daniel Borkmann wrote:
> On Mon, Sep 23, 2019 at 02:31:04PM -0700, Eric Dumazet wrote:
>> On 9/6/19 10:06 AM, Alexei Starovoitov wrote:
>>> On Fri, Sep 6, 2019 at 3:03 AM Yonghong Song <yhs@fb.com> wrote:
>>>> On 9/5/19 2:15 PM, Sami Tolvanen wrote:
>>>>> Instead of invoking struct bpf_prog::bpf_func directly, use the
>>>>> BPF_PROG_RUN macro.
>>>>>
>>>>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>>>>
>>>> Acked-by: Yonghong Song <yhs@fb.com>
>>>
>>> Applied. Thanks
>>
>> Then we probably need this as well, what do you think ?
>
> Yep, it's broken. 6cab5e90ab2b ("bpf: run bpf programs with preemption
> disabled") probably forgot about it since it wasn't using BPF_PROG_RUN()
> in the first place. If you get a chance, please send a proper patch,
> thanks!
Sure, I will send this today.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-09-24 19:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 21:15 [PATCH] kcm: use BPF_PROG_RUN Sami Tolvanen
2019-09-06 0:07 ` Yonghong Song
2019-09-06 17:06 ` Alexei Starovoitov
2019-09-23 21:31 ` Eric Dumazet
2019-09-24 18:59 ` Daniel Borkmann
2019-09-24 19:17 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).