bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: bpf: type fixes for __be16/__be32
@ 2019-10-16 11:16 Ben Dooks (Codethink)
  2019-10-17 17:12 ` Martin Lau
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Dooks (Codethink) @ 2019-10-16 11:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ben Dooks (Codethink),
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, David S. Miller, netdev, bpf, linux-kernel

In bpf_skb_load_helper_8_no_cache and
bpf_skb_load_helper_16_no_cache they
read a u16/u32 where actually these
are __be16 and __be32.

Fix the following by making the types
match:

net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:215:32: warning: cast to restricted __be16
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32
net/core/filter.c:242:32: warning: cast to restricted __be32

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 net/core/filter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index f7338fee41f8..eefb1545b4c6 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -205,7 +205,7 @@ BPF_CALL_2(bpf_skb_load_helper_8_no_cache, const struct sk_buff *, skb,
 BPF_CALL_4(bpf_skb_load_helper_16, const struct sk_buff *, skb, const void *,
 	   data, int, headlen, int, offset)
 {
-	u16 tmp, *ptr;
+	__be16 tmp, *ptr;
 	const int len = sizeof(tmp);
 
 	if (offset >= 0) {
@@ -232,7 +232,7 @@ BPF_CALL_2(bpf_skb_load_helper_16_no_cache, const struct sk_buff *, skb,
 BPF_CALL_4(bpf_skb_load_helper_32, const struct sk_buff *, skb, const void *,
 	   data, int, headlen, int, offset)
 {
-	u32 tmp, *ptr;
+	__be32 tmp, *ptr;
 	const int len = sizeof(tmp);
 
 	if (likely(offset >= 0)) {
-- 
2.23.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: bpf: type fixes for __be16/__be32
  2019-10-16 11:16 [PATCH] net: bpf: type fixes for __be16/__be32 Ben Dooks (Codethink)
@ 2019-10-17 17:12 ` Martin Lau
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Lau @ 2019-10-17 17:12 UTC (permalink / raw)
  To: Ben Dooks (Codethink)
  Cc: linux-kernel, Alexei Starovoitov, Daniel Borkmann, Song Liu,
	Yonghong Song, David S. Miller, netdev, bpf, linux-kernel

On Wed, Oct 16, 2019 at 12:16:35PM +0100, Ben Dooks (Codethink) wrote:
> In bpf_skb_load_helper_8_no_cache and
> bpf_skb_load_helper_16_no_cache they
> read a u16/u32 where actually these
> are __be16 and __be32.
> 
> Fix the following by making the types
> match:
> 
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:215:32: warning: cast to restricted __be16
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
> net/core/filter.c:242:32: warning: cast to restricted __be32
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-17 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 11:16 [PATCH] net: bpf: type fixes for __be16/__be32 Ben Dooks (Codethink)
2019-10-17 17:12 ` Martin Lau

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).