]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix _htons occurences in test_progs
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 26 Apr 2017 23:39:34 +0000 (01:39 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Apr 2017 19:48:15 +0000 (15:48 -0400)
commit509ba1dbff667ea77c28a896ced93ac9c2323426
tree96ccafc2cde1a7eb894f04ef7b337f8d6c3201b3
parent3bc4d6c9948db6163ab951addc58eb3f923c08ad
bpf: fix _htons occurences in test_progs

Dave reported that on sparc test_progs generates buggy swapped
eth->h_proto protocol comparisons:

  10: (15) if r3 == 0xdd86 goto pc+9
   R0=imm2,min_value=2,max_value=2 R1=pkt(id=0,off=0,r=14) R2=pkt_end R3=inv
   R4=pkt(id=0,off=14,r=14) R5=inv56 R10=fp

This is due to the unconditional ...

  #define htons __builtin_bswap16
  #define ntohs __builtin_bswap16

... in test_progs that causes this. Make use of asm/byteorder.h
and use __constant_htons() where possible and only perform the
bswap16 when on little endian in non-constant case.

Fixes: 4b97617c425b ("selftests/bpf: add a test for overlapping packet range checks")
Fixes: 3a099c9b8c0d ("selftests/bpf: add l4 load balancer test based on sched_cls")
Reported-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/bpf/bpf_util.h
tools/testing/selftests/bpf/test_l4lb.c
tools/testing/selftests/bpf/test_pkt_access.c
tools/testing/selftests/bpf/test_progs.c