Jiapeng Chong
bd2d4e6c6e
selftests/bpf: Simplify the calculation of variables
...
Fix the following coccicheck warnings:
./tools/testing/selftests/bpf/xdpxceiver.c:954:28-30: WARNING !A || A &&
B is equivalent to !A || B.
./tools/testing/selftests/bpf/xdpxceiver.c:932:28-30: WARNING !A || A &&
B is equivalent to !A || B.
./tools/testing/selftests/bpf/xdpxceiver.c:909:28-30: WARNING !A || A &&
B is equivalent to !A || B.
Reported-by: Abaci Robot <abaci@linux.alibaba.com >
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/1612860398-102839-1-git-send-email-jiapeng.chong@linux.alibaba.com
2021-02-10 12:14:27 -08:00
Björn Töpel
095af98652
selftests/bpf: Avoid useless void *-casts
...
There is no need to cast to void * when the argument is void *. Avoid
cluttering of code.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-13-bjorn.topel@gmail.com
2021-01-26 00:05:02 +01:00
Björn Töpel
d08a17d6de
selftests/bpf: Consistent malloc/calloc usage
...
Use calloc instead of malloc where it makes sense, and avoid C++-style
void *-cast.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-12-bjorn.topel@gmail.com
2021-01-26 00:05:02 +01:00
Björn Töpel
93dd4a06c0
selftests/bpf: Avoid heap allocation
...
The data variable is only used locally. Instead of using the heap,
stick to using the stack.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-11-bjorn.topel@gmail.com
2021-01-26 00:05:02 +01:00
Björn Töpel
829725ec7b
selftests/bpf: Define local variables at the beginning of a block
...
Use C89 rules for variable definition.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-10-bjorn.topel@gmail.com
2021-01-26 00:05:02 +01:00
Björn Töpel
59a4a87e4b
selftests/bpf: Change type from void * to struct generic_data *
...
Instead of casting from void *, let us use the actual type in
gen_udp_hdr().
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-9-bjorn.topel@gmail.com
2021-01-26 00:05:02 +01:00
Björn Töpel
124000e48b
selftests/bpf: Change type from void * to struct ifaceconfigobj *
...
Instead of casting from void *, let us use the actual type in
init_iface_config().
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-8-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Björn Töpel
0b50bd48cf
selftests/bpf: Remove casting by introduce local variable
...
Let us use a local variable in nsswitchthread(), so we can remove a
lot of casting for better readability.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-7-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Björn Töpel
8a9cba7ea8
selftests/bpf: Improve readability of xdpxceiver/worker_pkt_validate()
...
Introduce a local variable to get rid of lot of casting. Move common
code outside the if/else-clause.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-6-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Björn Töpel
4896d7e37e
selftests/bpf: Remove memory leak
...
The allocated entry is immediately overwritten by an assignment. Fix
that.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-5-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Björn Töpel
a86072838b
selftests/bpf: Fix style warnings
...
Silence three checkpatch style warnings.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-4-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Björn Töpel
7140ef1400
selftests/bpf: Remove a lot of ifobject casting
...
Instead of passing void * all over the place, let us pass the actual
type (ifobject) and remove the void-ptr-to-type-ptr casting.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20210122154725.22140-2-bjorn.topel@gmail.com
2021-01-26 00:05:01 +01:00
Colin Ian King
e79bb299cc
selftests/bpf: Fix spelling mistake "tranmission" -> "transmission"
...
There are two spelling mistakes in output messages. Fix these.
Signed-off-by: Colin Ian King <colin.king@canonical.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20201214223539.83168-1-colin.king@canonical.com
2020-12-18 16:13:02 +01:00
Weqaar Janjua
7d20441eb0
selftests/bpf: Xsk selftests - Bi-directional Sockets - SKB, DRV
...
Adds following tests:
1. AF_XDP SKB mode
d. Bi-directional Sockets
Configure sockets as bi-directional tx/rx sockets, sets up fill
and completion rings on each socket, tx/rx in both directions.
Only nopoll mode is used
2. AF_XDP DRV/Native mode
d. Bi-directional Sockets
* Only copy mode is supported because veth does not currently support
zero-copy mode
Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Tested-by: Yonghong Song <yhs@fb.com >
Acked-by: Björn Töpel <bjorn.topel@intel.com >
Link: https://lore.kernel.org/bpf/20201207215333.11586-6-weqaar.a.janjua@intel.com
2020-12-09 16:44:45 +01:00
Weqaar Janjua
6674bf6656
selftests/bpf: Xsk selftests - Socket Teardown - SKB, DRV
...
Adds following tests:
1. AF_XDP SKB mode
c. Socket Teardown
Create a Tx and a Rx socket, Tx from one socket, Rx on another.
Destroy both sockets, then repeat multiple times. Only nopoll mode
is used
2. AF_XDP DRV/Native mode
c. Socket Teardown
* Only copy mode is supported because veth does not currently support
zero-copy mode
Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Tested-by: Yonghong Song <yhs@fb.com >
Acked-by: Björn Töpel <bjorn.topel@intel.com >
Link: https://lore.kernel.org/bpf/20201207215333.11586-5-weqaar.a.janjua@intel.com
2020-12-09 16:44:45 +01:00
Weqaar Janjua
9103a8594d
selftests/bpf: Xsk selftests - DRV POLL, NOPOLL
...
Adds following tests:
2. AF_XDP DRV/Native mode
Works on any netdevice with XDP_REDIRECT support, driver dependent.
Processes packets before SKB allocation. Provides better performance
than SKB. Driver hook available just after DMA of buffer descriptor.
a. nopoll
b. poll
* Only copy mode is supported because veth does not currently support
zero-copy mode
Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Tested-by: Yonghong Song <yhs@fb.com >
Acked-by: Björn Töpel <bjorn.topel@intel.com >
Link: https://lore.kernel.org/bpf/20201207215333.11586-4-weqaar.a.janjua@intel.com
2020-12-09 16:44:45 +01:00
Weqaar Janjua
facb7cb2e9
selftests/bpf: Xsk selftests - SKB POLL, NOPOLL
...
Adds following tests:
1. AF_XDP SKB mode
Generic mode XDP is driver independent, used when the driver does
not have support for XDP. Works on any netdevice using sockets and
generic XDP path. XDP hook from netif_receive_skb().
a. nopoll - soft-irq processing
b. poll - using poll() syscall
Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Tested-by: Yonghong Song <yhs@fb.com >
Acked-by: Björn Töpel <bjorn.topel@intel.com >
Link: https://lore.kernel.org/bpf/20201207215333.11586-3-weqaar.a.janjua@intel.com
2020-12-09 16:44:45 +01:00