Re: [PATCH bpf-next 4/8] bpf: add PROG_TEST_RUN support for sk_lookup programs

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

 



On Tue, Feb 23, 2021 at 10:10:44AM +0000, Lorenz Bauer wrote:
> On Tue, 23 Feb 2021 at 01:11, Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > I'm struggling to come up with the case where running N sk_lookup progs
> > like this cannot be done with running them one by one.
> > It looks to me that this N prog_fds api is not really about running and
> > testing the progs, but about testing BPF_PROG_SK_LOOKUP_RUN_ARRAY()
> > SK_PASS vs SK_DROP logic.
> 
> In a way that is true, yes. TBH I figured that my patch set would be
> rejected if I just
> implemented single program test run, since it doesn't allow exercising the full
> sk_lookup test run semantics.
> 
> > So it's more of the kernel infra testing than program testing.
> > Are you suggesting that the sequence of sk_lookup progs are so delicate
> > that they are aware of each other and _has_ to be tested together
> > with gluing logic that the macro provides?
> 
> We currently don't have a case like that.
> 
> > But if it is so then testing the progs one by one would be better,
> > because test_run will be able to check each individual prog return code
> > instead of implicit BPF_PROG_SK_LOOKUP_RUN_ARRAY logic.
> 
> That means emulating the kind of subtle BPF_PROG_SK_LOOKUP_RUN_ARRAY
> in user space, which isn't trivial and a source of bugs.

I'm not at all suggesting to emulate it in user space.

> For example we rely on having multiple programs attached when
> "upgrading" from old to new BPF. Here we care mostly that we don't drop
> lookups on the floor, and the behaviour is tightly coupled to the in-kernel
> implementation. It's not much use to cobble up my own implementation of
> SK_LOOKUP_RUN_ARRAY here, I would rather use multi progs to test this.
> Of course we can also already spawn a netns and test it that way, so not
> much is lost if there is no multi prog test run.

I mean that to test the whole setup close to production the netns is
probably needed because sockets would mess with init_netns.
But to test each individual bpf prog there is no need for RUN_ARRAY.
Each prog can be more accurately tested in isolation.
RUN_ARRAY adds, as you said, subtle details of RUN_ARRAY macro.

> > It feels less of the unit test and more as a full stack test,
> > but if so then lack of cookie on input is questionable.
> 
> I'm not sure what you mean with "the lack of cookie on input is
> questionable", can you rephrase?
> 
> > In other words I'm struggling with in-between state of the api.
> > test_run with N fds is not really a full test, but not a unit test either.
> 
> If I understand you correctly, a "full" API would expose the
> intermediate results from
> individual programs as well as the final selection? Sounds quite
> complicated, and as
> you point out most of the benefits can be had from running single programs.

I'm not suggesting to return intermediate results either.
I'm looking at test_run as a facility to test one individual program
at a time. Like in tc, cgroups, tracing we can have multiple progs
attached to one place and the final verdict will depend on what
each prog is returning. But there is no need to test them all together
through BPF_PROG_CGROUP_INET_EGRESS_RUN_ARRAY.
Each prog is more accurately validated independently.
Hence I'm puzzled why sk_lookup's RUN_ARRAY is special.
Its drop/pass/selected sk is more or less the same complexity
as CGROUP_INET_EGRESS_RUN_ARRAY.



[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