Re: [PATCH v1 bpf-next 11/11] selftest: bpf: Test BPF_SOCK_OPS_(GEN|CHECK)_SYNCOOKIE_CB.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/13/23 3:04 PM, Kuniyuki Iwashima wrote:
This patch adds a test for BPF_SOCK_OPS_(GEN|CHECK)_SYNCOOKIE_CB hooks.

BPF_SOCK_OPS_GEN_SYNCOOKIE_CB hook generates a hash using SipHash from
based on 4-tuple.  The hash is split into ISN and TS.  MSS, ECN, SACK,
and WScale are encoded into the lower 8-bits of ISN.

   ISN:
     MSB                                   LSB
     | 31 ... 8 | 7 6 | 5   | 4    | 3 2 1 0 |
     | Hash_1   | MSS | ECN | SACK | WScale  |

   TS:
     MSB                LSB
     | 31 ... 8 | 7 ... 0 |
     | Random   | Hash_2  |

BPF_SOCK_OPS_CHECK_SYNCOOKIE_CB hook re-calculates the hash and validates
the cookie.

Signed-off-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
---
Currently, the validator is incomplete...

If this line is changed

     skops->replylong[0] = msstab[3];

to
     skops->replylong[0] = msstab[mssind];

, we will get the error below during make:

     GEN-SKEL [test_progs] test_tcp_syncookie.skel.h
   ...
   Error: failed to open BPF object file: No such file or directory

I cannot reprod. Does it have error earlier than this? GEN-SKEL is probably running this (make V=1 can tell):

tools/testing/selftests/bpf/tools/sbin/bpftool gen skeleton tools/testing/selftests/bpf/test_tcp_syncookie.bpf.linked3.o name test_tcp_syncookie > tools/testing/selftests/bpf/test_tcp_syncookie.skel.h

Add a "-d" to bpftool for more debug output: bpftool -d gen skeleton....


I cannot compile the patch in my environment as-is also:

In file included from progs/test_tcp_syncookie.c:6:
In file included from /data/users/kafai/fb-kernel/linux/tools/include/uapi/linux/tcp.h:22:
In file included from /usr/include/asm/byteorder.h:5:
In file included from /usr/include/linux/byteorder/little_endian.h:13:
/usr/include/linux/swab.h:136:8: error: unknown type name '__always_inline'
  136 | static __always_inline unsigned long __swab(const unsigned long y)

I have to add a "#include <linux/stddef.h>".


     GEN-SKEL [test_progs-no_alu32] test_tcp_syncookie.skel.h
   make: *** [Makefile:603: /home/ec2-user/kernel/bpf_syncookie/tools/testing/selftests/bpf/test_tcp_syncookie.skel.h] Error 254
   make: *** Deleting file '/home/ec2-user/kernel/bpf_syncookie/tools/testing/selftests/bpf/test_tcp_syncookie.skel.h'
   make: *** Waiting for unfinished jobs....





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux