diff mbox series

[v2,2/2] tcindex01: Pass if the tcindex module is blacklisted

Message ID 20240515134432.27996-2-mdoucha@suse.cz
State Accepted
Headers show
Series [v2,1/2] tst_netdevice: Add permissive macro for adding traffic filters | expand

Commit Message

Martin Doucha May 15, 2024, 1:44 p.m. UTC
The tcindex01 test currently fails if the tcindex module is enabled
in kernel config but cannot be autoloaded. Some distros chose
to blacklist the module rather than remove it completely, thus
check for autoload failure and pass in that case.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- Use NETDEV_ADD_TRAFFIC_FILTER_RET() macro instead of the underlying function

 testcases/cve/tcindex01.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Comments

Cyril Hrubis May 15, 2024, 2:03 p.m. UTC | #1
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel May 16, 2024, 1:12 a.m. UTC | #2
Hi Martin, Cyril,

patchset merged. Thanks to both!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/cve/tcindex01.c b/testcases/cve/tcindex01.c
index 70e5639f1..e9c8a9a90 100644
--- a/testcases/cve/tcindex01.c
+++ b/testcases/cve/tcindex01.c
@@ -106,12 +106,23 @@  static void run(void)
 	NETDEV_ADD_QDISC(DEVNAME, AF_UNSPEC, TC_H_ROOT, qd_handle, "htb",
 		qd_config);
 	NETDEV_ADD_TRAFFIC_CLASS(DEVNAME, qd_handle, clsid, "htb", cls_config);
-	NETDEV_ADD_TRAFFIC_FILTER(DEVNAME, qd_handle, 10, ETH_P_IP, 1,
-		"tcindex", f_config);
+	ret = NETDEV_ADD_TRAFFIC_FILTER_RET(DEVNAME, qd_handle, 10, ETH_P_IP,
+		1, "tcindex", f_config);
+	TST_ERR = tst_netlink_errno;
+
+	if (!ret && TST_ERR == ENOENT) {
+		tst_res(TPASS | TTERRNO,
+			"tcindex module is blacklisted or unavailable");
+		return;
+	}
+
+	if (!ret)
+		tst_brk(TBROK | TTERRNO, "Cannot add tcindex filter");
+
 	NETDEV_REMOVE_TRAFFIC_FILTER(DEVNAME, qd_handle, 10, ETH_P_IP,
 		1, "tcindex");
-	ret = tst_netdev_add_traffic_filter(__FILE__, __LINE__, 0, DEVNAME,
-		qd_handle, 10, ETH_P_IP, 1, "tcindex", f_config);
+	ret = NETDEV_ADD_TRAFFIC_FILTER_RET(DEVNAME, qd_handle, 10, ETH_P_IP,
+		1, "tcindex", f_config);
 	TST_ERR = tst_netlink_errno;
 	NETDEV_REMOVE_QDISC(DEVNAME, AF_UNSPEC, TC_H_ROOT, qd_handle, "htb");