Re: [bug report] selftests/bpf: Tests using bpf_check_mtu BPF-helper

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

 





On 06/06/2023 10.30, Dan Carpenter wrote:
Hello Jesper Dangaard Brouer,

The patch b62eba563229: "selftests/bpf: Tests using bpf_check_mtu
BPF-helper" from Feb 9, 2021, leads to the following Smatch static
checker warning:


Thanks for reporting this!

	./tools/testing/selftests/bpf/prog_tests/check_mtu.c:192 serial_test_check_mtu()
	warn: unsigned 'mtu_lo' is never less than zero.

./tools/testing/selftests/bpf/prog_tests/check_mtu.c
     184 void serial_test_check_mtu(void)
     185 {
     186         __u32 mtu_lo;
                 ^^^^^^^^^^^^


This should have been an 'int', because read_mtu_device_lo() uses minus as error indication.

I'll send a fix patch shortly.

     187
     188         if (test__start_subtest("bpf_check_mtu XDP-attach"))
     189                 test_check_mtu_xdp_attach();
     190
     191         mtu_lo = read_mtu_device_lo();
--> 192         if (CHECK(mtu_lo < 0, "reading MTU value", "failed (err:%d)", mtu_lo))
                           ^^^^^^^^^^
Unsigned can't be less than zero.

     193                 return;
     194
     195         if (test__start_subtest("bpf_check_mtu XDP-run"))
     196                 test_check_mtu_xdp(mtu_lo, 0);
     197
     198         if (test__start_subtest("bpf_check_mtu XDP-run ifindex-lookup"))
     199                 test_check_mtu_xdp(mtu_lo, IFINDEX_LO);
     200
     201         if (test__start_subtest("bpf_check_mtu TC-run"))
     202                 test_check_mtu_tc(mtu_lo, 0);
     203
     204         if (test__start_subtest("bpf_check_mtu TC-run ifindex-lookup"))
     205                 test_check_mtu_tc(mtu_lo, IFINDEX_LO);
     206 }

regards,
dan carpenter


--Jesper




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux