From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 05/18] Makefile, conf, passt: Drop passt4netns references, explicit argc check Date: Tue, 22 Feb 2022 02:34:21 +0100 Message-ID: <20220222013434.4116044-6-sbrivio@redhat.com> In-Reply-To: <20220222013434.4116044-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7626777779587252899==" --===============7626777779587252899== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Nobody currently calls this as passt4netns, that was the name I used before 'pasta', drop any reference before it's too late. While at it, explicitly check that argc is bigger than or equal to one, just as a defensive measure: argv[0] being NULL is not an issue anyway. Signed-off-by: Stefano Brivio --- Makefile | 7 ++----- conf.c | 12 ++++++------ passt.c | 9 +++++++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 5085578..8477cf0 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ endif prefix ?= /usr/local -all: passt pasta passt4netns qrap +all: passt pasta qrap avx2: CFLAGS += -Ofast -mavx2 -ftree-vectorize -funroll-loops avx2: clean all @@ -81,16 +81,13 @@ pasta: passt ln -s passt pasta ln -s passt.1 pasta.1 -passt4netns: passt - ln -s passt passt4netns - qrap: qrap.c passt.h $(CC) $(CFLAGS) \ qrap.c -o qrap .PHONY: clean clean: - -${RM} passt *.o seccomp.h qrap pasta pasta.1 passt4netns \ + -${RM} passt *.o seccomp.h qrap pasta pasta.1 \ passt.tar passt.tar.gz *.deb *.rpm install: passt pasta qrap diff --git a/conf.c b/conf.c index 732d918..2984ac2 100644 --- a/conf.c +++ b/conf.c @@ -532,7 +532,7 @@ static void conf_ip(struct ctx *c) */ static void usage(const char *name) { - if (strstr(name, "pasta") || strstr(name, "passt4netns")) { + if (strstr(name, "pasta")) { info("Usage: %s [OPTION]... [PID|PATH|NAME]", name); info(""); info("Without PID|PATH|NAME, run the default shell in a new"); @@ -550,7 +550,7 @@ static void usage(const char *name) info( " default: log to system logger only if started from a TTY"); info( " -h, --help Display this help message and exit"); - if (strstr(name, "pasta") || strstr(name, "passt4netns")) { + if (strstr(name, "pasta")) { info( " -I, --ns-ifname NAME namespace interface name"); info( " default: same interface name as external one"); } else { @@ -562,7 +562,7 @@ static void usage(const char *name) info( " -p, --pcap [FILE] Log tap-facing traffic to pcap file"); info( " if FILE is not given, log to:"); - if (strstr(name, "pasta") || strstr(name, "passt4netns")) + if (strstr(name, "pasta")) info(" /tmp/pasta_ISO8601-TIMESTAMP_PID.pcap"); else info(" /tmp/passt_ISO8601-TIMESTAMP_PID.pcap"); @@ -586,14 +586,14 @@ static void usage(const char *name) info( " -D, --dns ADDR Pass IPv4 or IPv6 address as DNS"); info( " can be specified multiple times"); info( " a single, empty option disables DNS information"); - if (strstr(name, "pasta") || strstr(name, "passt4netns")) + if (strstr(name, "pasta")) info( " default: don't send any addresses"); else info( " default: use addresses from /etc/resolv.conf"); info( " -S, --search LIST Space-separated list, search domains"); info( " a single, empty option disables the DNS search list"); - if (strstr(name, "pasta") || strstr(name, "passt4netns")) + if (strstr(name, "pasta")) info( " default: don't send any search list"); else info( " default: use search list from /etc/resolv.conf"); @@ -609,7 +609,7 @@ static void usage(const char *name) info( " -4, --ipv4-only Enable IPv4 operation only"); info( " -6, --ipv6-only Enable IPv6 operation only"); - if (strstr(name, "pasta") || strstr(name, "passt4netns")) + if (strstr(name, "pasta")) goto pasta_opts; info( " -t, --tcp-ports SPEC TCP port forwarding to guest"); diff --git a/passt.c b/passt.c index b5086d8..67ad1c7 100644 --- a/passt.c +++ b/passt.c @@ -322,16 +322,21 @@ int main(int argc, char **argv) sigaction(SIGTERM, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); - if (strstr(argv[0], "pasta") || strstr(argv[0], "passt4netns")) { + if (argc < 1) + exit(EXIT_FAILURE); + + if (strstr(argv[0], "pasta")) { sa.sa_handler = pasta_child_handler; sigaction(SIGCHLD, &sa, NULL); signal(SIGPIPE, SIG_IGN); c.mode = MODE_PASTA; log_name = "pasta"; - } else { + } else if (strstr(argv[0], "passt")) { c.mode = MODE_PASST; log_name = "passt"; + } else { + exit(EXIT_FAILURE); } if (madvise(pkt_buf, TAP_BUF_BYTES, MADV_HUGEPAGE)) -- 2.34.1 --===============7626777779587252899==--