Re: [PATCH bpf-next 2/6] selftests/bpf: add missing ns cleanups in btf_skc_cls_ingress

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

 



Hi Martin, thanks for the review !

On 10/19/24 01:57, Martin KaFai Lau wrote:
> On 10/16/24 11:35 AM, Alexis Lothoré (eBPF Foundation) wrote:
>> btf_skc_cls_ingress.c currently runs two subtests, and create a
>> dedicated network namespace for each, but never cleans up the created
>> namespace once the test has ended.
>>
>> Add missing namespace cleanup after each namespace to avoid accumulating
>> namespaces for each new subtest. While at it, switch namespace
>> management to netns_{new,free}
>>
>> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@xxxxxxxxxxx>

[...]

>>   -    if (CHECK(unshare(CLONE_NEWNET), "create netns",
>> -          "unshare(CLONE_NEWNET): %s (%d)",
>> -          strerror(errno), errno))
>> -        return -1;
>> +    ns = netns_new(TEST_NS, true);
>> +    if (!ASSERT_OK_PTR(ns, "create and join netns"))
>> +        return ns;
>>         if (CHECK(system("ip link set dev lo up"),
>>             "ip link set dev lo up", "failed\n"))
> 
> nit. netns_new() takes care of "lo up" also, so the above can be removed.

Ah, indeed, I missed it in make_netns. Thanks, I'll remove this part from the
test then.
> 
> test_progs.c has restore_netns() after each test, so the netns was not cleaned
> up. The second unshare should have freed the earlier netns also.
> 
> Using netns_new() removed the boiler plate codes. It is nice to see this change
> here regardless.



-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




[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