Skip to contentSkip to conversation

selftests/bpf: don't hardcode iptables/nc path in test_tcpnotify_user

PATCH Applied Stanislav Fomichev 2 participants 2 messages Jan 17, 2019 – Jan 23, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: don't hardcode iptables/nc path in test_tcpnotify_user

system() is calling shell which should find the appropriate full path via $PATH. On some systems, full path to iptables and/or nc might be different that we one we have hardcoded.

---
 tools/testing/selftests/bpf/test_tcpnotify_user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/test_tcpnotify_user.c +3 -3
index 4e4353711a86..86152d9ae95b 100644
@@ -148,17 +148,17 @@ int main(int argc, char **argv)
 	pthread_create(&tid, NULL, poller_thread, (void *)&pmu_fd);
 
 	sprintf(test_script,
-		"/usr/sbin/iptables -A INPUT -p tcp --dport %d -j DROP",
+		"iptables -A INPUT -p tcp --dport %d -j DROP",
 		TESTPORT);
 	system(test_script);
 
 	sprintf(test_script,
-		"/usr/bin/nc 127.0.0.1 %d < /etc/passwd > /dev/null 2>&1 ",
+		"nc 127.0.0.1 %d < /etc/passwd > /dev/null 2>&1 ",
 		TESTPORT);
 	system(test_script);
 
 	sprintf(test_script,
-		"/usr/sbin/iptables -D INPUT -p tcp --dport %d -j DROP",
+		"iptables -D INPUT -p tcp --dport %d -j DROP",
 		TESTPORT);
 	system(test_script);
 
Signature · 1 line
2.20.1.97.g81188d93c3-goog
maintainer Applied
#1 lore raw
Quoted 5 lines · Stanislav Fomichev

system() is calling shell which should find the appropriate full path via $PATH. On some systems, full path to iptables and/or nc might be different that we one we have hardcoded.

Applied, thanks!