* [LTP] [PATCH v4] kernel/uevent: Adjust the number of uevents dynamically in uevent02
@ 2022-09-19 7:43 Dylan Jhong
2022-09-20 13:02 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Dylan Jhong @ 2022-09-19 7:43 UTC (permalink / raw)
To: ltp, chrubis; +Cc: alankao, minachou, dminus, x5710999x
When CONFIG_SMP is not selected, CONFIG_RPS will not be enabled. Causes the
kernel to not create rx queues in sysfs[1] when creating tun devices.
Uevent02 will check if the rx queue exists, adjust the uevents dynamically
in setup() to pass this test.
[1]: https://github.com/torvalds/linux/blob/3245cb65fd91cd514801bf91f5a3066d562f0ac4/net/core/net-sysfs.c#L1109
Signed-off-by: Dylan Jhong <dylan@andestech.com>
---
testcases/kernel/uevents/uevent02.c | 160 +++++++++++++++-------------
1 file changed, 88 insertions(+), 72 deletions(-)
diff --git a/testcases/kernel/uevents/uevent02.c b/testcases/kernel/uevents/uevent02.c
index ce0cf757d..4355cd8db 100644
--- a/testcases/kernel/uevents/uevent02.c
+++ b/testcases/kernel/uevents/uevent02.c
@@ -18,11 +18,77 @@
#include <linux/if.h>
#include <linux/if_tun.h>
+#include "tst_kconfig.h"
#include "tst_test.h"
#include "uevent.h"
#define TUN_PATH "/dev/net/tun"
+#define CONFIG_RPS "CONFIG_RPS"
+#define MAX_UEVENTS 7
+
+static struct uevent_desc add = {
+ .msg = "add@/devices/virtual/net/ltp-tun0",
+ .value_cnt = 4,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0",
+ "SUBSYSTEM=net",
+ "INTERFACE=ltp-tun0",
+ }
+};
+
+static struct uevent_desc add_rx = {
+ .msg = "add@/devices/virtual/net/ltp-tun0/queues/rx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+
+static struct uevent_desc add_tx = {
+ .msg = "add@/devices/virtual/net/ltp-tun0/queues/tx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+
+static struct uevent_desc rem_rx = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0/queues/rx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+
+static struct uevent_desc rem_tx = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0/queues/tx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+
+static struct uevent_desc rem = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0",
+ .value_cnt = 4,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0",
+ "SUBSYSTEM=net",
+ "INTERFACE=ltp-tun0",
+ }
+};
+static const struct uevent_desc *uevents[MAX_UEVENTS];
static void generate_tun_uevents(void)
{
@@ -44,78 +110,6 @@ static void verify_uevent(void)
{
int pid, fd;
- struct uevent_desc add = {
- .msg = "add@/devices/virtual/net/ltp-tun0",
- .value_cnt = 4,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0",
- "SUBSYSTEM=net",
- "INTERFACE=ltp-tun0",
- }
- };
-
- struct uevent_desc add_rx = {
- .msg = "add@/devices/virtual/net/ltp-tun0/queues/rx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc add_tx = {
- .msg = "add@/devices/virtual/net/ltp-tun0/queues/tx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem_rx = {
- .msg = "remove@/devices/virtual/net/ltp-tun0/queues/rx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem_tx = {
- .msg = "remove@/devices/virtual/net/ltp-tun0/queues/tx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem = {
- .msg = "remove@/devices/virtual/net/ltp-tun0",
- .value_cnt = 4,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0",
- "SUBSYSTEM=net",
- "INTERFACE=ltp-tun0",
- }
- };
-
- const struct uevent_desc *const uevents[] = {
- &add,
- &add_rx,
- &add_tx,
- &rem_rx,
- &rem_tx,
- &rem,
- NULL
- };
-
pid = SAFE_FORK();
if (!pid) {
fd = open_uevent_netlink();
@@ -131,7 +125,29 @@ static void verify_uevent(void)
wait_for_pid(pid);
}
+static void setup(void)
+{
+ struct tst_kconfig_var kconfig = {
+ .id = CONFIG_RPS,
+ .id_len = sizeof(CONFIG_RPS) - 1,
+ };
+ int i = 0;
+
+ tst_kconfig_read(&kconfig, 1);
+
+ uevents[i++] = &add;
+ if (kconfig.choice == 'y')
+ uevents[i++] = &add_rx;
+ uevents[i++] = &add_tx;
+ if (kconfig.choice == 'y')
+ uevents[i++] = &rem_rx;
+ uevents[i++] = &rem_tx;
+ uevents[i++] = &rem;
+ uevents[i++] = NULL;
+}
+
static struct tst_test test = {
+ .setup = setup,
.test_all = verify_uevent,
.forks_child = 1,
.needs_checkpoints = 1,
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH v4] kernel/uevent: Adjust the number of uevents dynamically in uevent02
2022-09-19 7:43 [LTP] [PATCH v4] kernel/uevent: Adjust the number of uevents dynamically in uevent02 Dylan Jhong
@ 2022-09-20 13:02 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-09-20 13:02 UTC (permalink / raw)
To: Dylan Jhong; +Cc: alankao, minachou, dminus, x5710999x, ltp
Hi!
> When CONFIG_SMP is not selected, CONFIG_RPS will not be enabled. Causes the
> kernel to not create rx queues in sysfs[1] when creating tun devices.
> Uevent02 will check if the rx queue exists, adjust the uevents dynamically
> in setup() to pass this test.
>
> [1]: https://github.com/torvalds/linux/blob/3245cb65fd91cd514801bf91f5a3066d562f0ac4/net/core/net-sysfs.c#L1109
Pushed, thanks.
> Signed-off-by: Dylan Jhong <dylan@andestech.com>
> ---
It's customary to add a note here (after the ---) about changes done
since the last patch revision, sometimes it's hard to spot the change
without a hint. In this case I nearly missed the difference since it
was one static keyword missing in v3.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-20 13:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 7:43 [LTP] [PATCH v4] kernel/uevent: Adjust the number of uevents dynamically in uevent02 Dylan Jhong
2022-09-20 13:02 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.