]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
2a383a542f5c91782333effd37e3482829ed26b1
[thirdparty/kernel/stable-queue.git] /
1 From pulehui@huaweicloud.com Sun Nov 10 06:09:10 2024
2 From: Pu Lehui <pulehui@huaweicloud.com>
3 Date: Thu, 31 Oct 2024 06:37:02 +0000
4 Subject: Revert "selftests/bpf: Implement get_hw_ring_size function to retrieve current and max interface size"
5 To: stable@vger.kernel.org, bpf@vger.kernel.org
6 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, Pu Lehui <pulehui@huawei.com>
7 Message-ID: <20241031063702.3256343-1-pulehui@huaweicloud.com>
8
9 From: Pu Lehui <pulehui@huawei.com>
10
11 This reverts commit c8c590f07ad7ffaa6ef11e90b81202212077497b which is
12 commit 90a695c3d31e1c9f0adb8c4c80028ed4ea7ed5ab upstream.
13
14 Commit c8c590f07ad7 ("selftests/bpf: Implement get_hw_ring_size function
15 to retrieve current and max interface size") will cause the following
16 bpf selftests compilation error in the 6.6 stable branch, and it is not
17 the Stable-dep-of of commit 103c0431c7fb ("selftests/bpf: Drop unneeded
18 error.h includes"). So let's revert commit c8c590f07ad7 to fix this
19 compilation error.
20
21 ./network_helpers.h:66:43: error: 'struct ethtool_ringparam' declared
22 inside parameter list will not be visible outside of this definition or
23 declaration [-Werror]
24 66 | int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param);
25
26 Signed-off-by: Pu Lehui <pulehui@huawei.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 ---
29 tools/testing/selftests/bpf/network_helpers.c | 24 ----------------
30 tools/testing/selftests/bpf/network_helpers.h | 4 --
31 tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 1
32 tools/testing/selftests/bpf/xdp_hw_metadata.c | 14 +++++++++
33 4 files changed, 15 insertions(+), 28 deletions(-)
34
35 --- a/tools/testing/selftests/bpf/network_helpers.c
36 +++ b/tools/testing/selftests/bpf/network_helpers.c
37 @@ -465,27 +465,3 @@ int get_socket_local_port(int sock_fd)
38
39 return -1;
40 }
41 -
42 -int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
43 -{
44 - struct ifreq ifr = {0};
45 - int sockfd, err;
46 -
47 - sockfd = socket(AF_INET, SOCK_DGRAM, 0);
48 - if (sockfd < 0)
49 - return -errno;
50 -
51 - memcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
52 -
53 - ring_param->cmd = ETHTOOL_GRINGPARAM;
54 - ifr.ifr_data = (char *)ring_param;
55 -
56 - if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {
57 - err = errno;
58 - close(sockfd);
59 - return -err;
60 - }
61 -
62 - close(sockfd);
63 - return 0;
64 -}
65 --- a/tools/testing/selftests/bpf/network_helpers.h
66 +++ b/tools/testing/selftests/bpf/network_helpers.h
67 @@ -9,11 +9,8 @@ typedef __u16 __sum16;
68 #include <linux/if_packet.h>
69 #include <linux/ip.h>
70 #include <linux/ipv6.h>
71 -#include <linux/ethtool.h>
72 -#include <linux/sockios.h>
73 #include <netinet/tcp.h>
74 #include <bpf/bpf_endian.h>
75 -#include <net/if.h>
76
77 #define MAGIC_VAL 0x1234
78 #define NUM_ITER 100000
79 @@ -63,7 +60,6 @@ int make_sockaddr(int family, const char
80 struct sockaddr_storage *addr, socklen_t *len);
81 char *ping_command(int family);
82 int get_socket_local_port(int sock_fd);
83 -int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param);
84
85 struct nstoken;
86 /**
87 --- a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
88 +++ b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
89 @@ -2,6 +2,7 @@
90 #define _GNU_SOURCE
91 #include <test_progs.h>
92 #include <network_helpers.h>
93 +#include <linux/if.h>
94 #include <linux/if_tun.h>
95 #include <sys/uio.h>
96
97 --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
98 +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
99 @@ -288,6 +288,20 @@ static int verify_metadata(struct xsk *r
100 return 0;
101 }
102
103 +struct ethtool_channels {
104 + __u32 cmd;
105 + __u32 max_rx;
106 + __u32 max_tx;
107 + __u32 max_other;
108 + __u32 max_combined;
109 + __u32 rx_count;
110 + __u32 tx_count;
111 + __u32 other_count;
112 + __u32 combined_count;
113 +};
114 +
115 +#define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */
116 +
117 static int rxq_num(const char *ifname)
118 {
119 struct ethtool_channels ch = {