[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMEtUuz0SxSoSeJk7_C7Qt1t_27wqkp__Hk1CT13TgzhJGUUcg@mail.gmail.com>
Date: Thu, 27 Mar 2014 13:30:47 -0700
From: Alexei Starovoitov <ast@...mgrid.com>
To: David Miller <davem@...emloft.net>
Cc: Daniel Borkmann <dborkman@...hat.com>,
Network Development <netdev@...r.kernel.org>,
Hagen Paul Pfeifer <hagen@...u.net>,
Kees Cook <keescook@...omium.org>, pmoore@...hat.com,
Ingo Molnar <mingo@...nel.org>, hpa@...ux.intel.com,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next v3 8/9] net: filter: rework/optimize internal BPF
interpreter's instruction set
On Thu, Mar 27, 2014 at 12:23 PM, David Miller <davem@...emloft.net> wrote:
> From: Daniel Borkmann <dborkman@...hat.com>
> Date: Wed, 26 Mar 2014 22:06:09 +0100
>
>> - Adds swab insns for 32/64-bit
>
> I don't like this.
>
> You don't want a swab instruction, you want "endian X to endian Y". Just
> like we have "cpu_to_le32()", "le32_to_cpu()" et al. in the kernel.
>
> That way the user can be completely oblivious as to the endianness of
> the cpu it's running on.
Agreed.
If we want to expose ebpf instruction set to the userspace as-is then
it completely makes sense.
The reason we picked swab style is two fold:
1. swab32/64 maps as-is to native cpu instructions during jit.
2. assumption was that new_socket_filters/tracing_filters/ovs_filters
will be written in C and will use standard macro ntohl() that
will be expanded to __builtin_swap or nop by gcc/llvm,
so users don't need to worry about underlying endianness while
writing filters in C.
> So if you ask for a "to little endian" swab, if the chip is
> little-endian then no code needs to be emitted at all, it's a nop.
>
> There is zero reason for the BPF program emitted by userspace to be
> dependant upon the cpu endianness.
Agree.
with cpu_to_le and cpu_to_be instructions the programs written in C
and written directly in ebpf won't need to worry about endianness.
Best of both.
We'll fix and resend.
Thanks
Alexei
--
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