* [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction
@ 2014-11-10 5:59 Denis Kirjanov
2014-11-10 18:26 ` Alexei Starovoitov
2014-11-11 18:40 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Denis Kirjanov @ 2014-11-10 5:59 UTC (permalink / raw)
To: netdev
Cc: Philippe Bergheaud, linuxppc-dev, Denis Kirjanov, Daniel Borkmann,
Alexei Starovoitov
Add BPF extension SKF_AD_HATYPE to ppc JIT to check
the hw type of the interface
Before:
[ 57.723666] test_bpf: #20 LD_HATYPE
[ 57.723675] BPF filter opcode 0020 (@0) unsupported
[ 57.724168] 48 48 PASS
After:
[ 103.053184] test_bpf: #20 LD_HATYPE 7 6 PASS
CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
CC: Daniel Borkmann<dborkman@redhat.com>
CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
v2: address Alexei's comments
---
arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index d110e28..d3fa80d 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -361,6 +361,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
protocol));
break;
case BPF_ANC | SKF_AD_IFINDEX:
+ case BPF_ANC | SKF_AD_HATYPE:
+ BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
+ ifindex) != 4);
+ BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
+ type) != 2);
PPC_LD_OFFS(r_scratch1, r_skb, offsetof(struct sk_buff,
dev));
PPC_CMPDI(r_scratch1, 0);
@@ -368,14 +373,18 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]);
} else {
/* Exit, returning 0; first pass hits here. */
- PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12);
+ PPC_BCC_SHORT(COND_NE, ctx->idx * 4 + 12);
PPC_LI(r_ret, 0);
PPC_JMP(exit_addr);
}
- BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
- ifindex) != 4);
- PPC_LWZ_OFFS(r_A, r_scratch1,
+ if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
+ PPC_LWZ_OFFS(r_A, r_scratch1,
offsetof(struct net_device, ifindex));
+ } else {
+ PPC_LHZ_OFFS(r_A, r_scratch1,
+ offsetof(struct net_device, type));
+ }
+
break;
case BPF_ANC | SKF_AD_MARK:
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, mark) != 4);
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction
2014-11-10 5:59 [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction Denis Kirjanov
@ 2014-11-10 18:26 ` Alexei Starovoitov
2014-11-11 18:40 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2014-11-10 18:26 UTC (permalink / raw)
To: Denis Kirjanov
Cc: Philippe Bergheaud, netdev@vger.kernel.org, Daniel Borkmann,
linuxppc-dev
On Sun, Nov 9, 2014 at 9:59 PM, Denis Kirjanov <kda@linux-powerpc.org> wrote:
> Add BPF extension SKF_AD_HATYPE to ppc JIT to check
> the hw type of the interface
>
> Before:
> [ 57.723666] test_bpf: #20 LD_HATYPE
> [ 57.723675] BPF filter opcode 0020 (@0) unsupported
> [ 57.724168] 48 48 PASS
>
> After:
> [ 103.053184] test_bpf: #20 LD_HATYPE 7 6 PASS
>
> CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
> CC: Daniel Borkmann<dborkman@redhat.com>
> CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>
> v2: address Alexei's comments
> ---
> arch/powerpc/net/bpf_jit_comp.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index d110e28..d3fa80d 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -361,6 +361,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
> protocol));
> break;
> case BPF_ANC | SKF_AD_IFINDEX:
> + case BPF_ANC | SKF_AD_HATYPE:
> + BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
> + ifindex) != 4);
> + BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
> + type) != 2);
> PPC_LD_OFFS(r_scratch1, r_skb, offsetof(struct sk_buff,
> dev));
> PPC_CMPDI(r_scratch1, 0);
> @@ -368,14 +373,18 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
> PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]);
> } else {
> /* Exit, returning 0; first pass hits here. */
> - PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12);
> + PPC_BCC_SHORT(COND_NE, ctx->idx * 4 + 12);
> PPC_LI(r_ret, 0);
> PPC_JMP(exit_addr);
> }
> - BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
> - ifindex) != 4);
> - PPC_LWZ_OFFS(r_A, r_scratch1,
> + if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
> + PPC_LWZ_OFFS(r_A, r_scratch1,
> offsetof(struct net_device, ifindex));
> + } else {
> + PPC_LHZ_OFFS(r_A, r_scratch1,
> + offsetof(struct net_device, type));
formatting is a bit off here, but that's minor.
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction
2014-11-10 5:59 [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction Denis Kirjanov
2014-11-10 18:26 ` Alexei Starovoitov
@ 2014-11-11 18:40 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-11-11 18:40 UTC (permalink / raw)
To: kda; +Cc: felix, netdev, dborkman, alexei.starovoitov, linuxppc-dev
From: Denis Kirjanov <kda@linux-powerpc.org>
Date: Mon, 10 Nov 2014 08:59:43 +0300
> Add BPF extension SKF_AD_HATYPE to ppc JIT to check
> the hw type of the interface
>
> Before:
> [ 57.723666] test_bpf: #20 LD_HATYPE
> [ 57.723675] BPF filter opcode 0020 (@0) unsupported
> [ 57.724168] 48 48 PASS
>
> After:
> [ 103.053184] test_bpf: #20 LD_HATYPE 7 6 PASS
>
> CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
> CC: Daniel Borkmann<dborkman@redhat.com>
> CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>
> v2: address Alexei's comments
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-11 18:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 5:59 [PATCH v2 net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction Denis Kirjanov
2014-11-10 18:26 ` Alexei Starovoitov
2014-11-11 18:40 ` David Miller
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).