[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 31 Dec 2012 19:25:49 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Daniel Borkmann <dborkman@...hat.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 5/8] net: bpf: add neq jump operations to bpf
machine
On Mon, 2012-12-31 at 14:59 +0100, Daniel Borkmann wrote:
> This patch adds jump operations for neq (!=) that compare A
> with K resp. X in order to facilitate filter programming with
> conditional jumps, since currently only eq (==) is present in
> the BPF machine. For user-space filter programming / compilers,
> it might be good to also have this complementary operation.
> They don't need to be as ancillary, since they fit into the
> instruction encoding directly. Follow-up BPF JIT patches are
> welcomed.
>
> Signed-off-by: Daniel Borkmann <dborkman@...hat.com>
> ---
> include/linux/filter.h | 2 ++
> include/uapi/linux/filter.h | 1 +
> net/core/filter.c | 14 ++++++++++++++
> 3 files changed, 17 insertions(+)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 36630bc..256c01f 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -105,6 +105,8 @@ enum {
> BPF_S_JMP_JA,
> BPF_S_JMP_JEQ_K,
> BPF_S_JMP_JEQ_X,
> + BPF_S_JMP_JNEQ_K,
> + BPF_S_JMP_JNEQ_X,
> BPF_S_JMP_JGE_K,
> BPF_S_JMP_JGE_X,
> BPF_S_JMP_JGT_K,
> diff --git a/include/uapi/linux/filter.h b/include/uapi/linux/filter.h
> index 3ebcc2e..d909a6f 100644
> --- a/include/uapi/linux/filter.h
> +++ b/include/uapi/linux/filter.h
> @@ -80,6 +80,7 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
> #define BPF_JSET 0x40
> #define BPF_JLT 0x50
> #define BPF_JLE 0x60
> +#define BPF_JNEQ 0x70
>
> #define BPF_SRC(code) ((code) & 0x08)
> #define BPF_K 0x00
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 2122eba..b360fb3 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -228,6 +228,9 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
> case BPF_S_JMP_JEQ_K:
> fentry += (A == K) ? fentry->jt : fentry->jf;
> continue;
> + case BPF_S_JMP_JNEQ_K:
> + fentry += (A != K) ? fentry->jt : fentry->jf;
> + continue;
> case BPF_S_JMP_JSET_K:
> fentry += (A & K) ? fentry->jt : fentry->jf;
> continue;
This makes no sense at all to me, it seems kernel bloat.
The JNE instruction already exists.
You only have to take the JEQ (jt,jf) and swap the jt/jf targets.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists