From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 1DA5D5A0265 for ; Tue, 11 Oct 2022 02:13:06 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4MmbpQ3fPPz4wgr; Tue, 11 Oct 2022 11:13:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1665447182; bh=CIM5l5AEggknhakaESn/XNtASjFAqQwRL6HdbPOaIh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hALivCEfE53goQPQz8anTvCLzZ9Nns8+6a6H29czfOjMVoNC7DY4zKUNsuUOzxvxT 3W1HtX23nxVJrkWoZfM+fsF/lxZfuMz7nLgM9mghCmtEEM5+hd+LNJiMgu3byHtw84 UCkHGSz1XT0kEwOs9C3edwiTISmcyHbkDYrJ6U/4= Date: Tue, 11 Oct 2022 11:12:34 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 6/7] conf, log, Makefile: Add versioning information Message-ID: References: <20221010083548.831309-1-sbrivio@redhat.com> <20221010083548.831309-7-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VvuhfgdxhqW4hiQB" Content-Disposition: inline In-Reply-To: <20221010083548.831309-7-sbrivio@redhat.com> Message-ID-Hash: MVC7Z24PJO5CXHV2NQJWGGYXK7WJNXZZ X-Message-ID-Hash: MVC7Z24PJO5CXHV2NQJWGGYXK7WJNXZZ X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --VvuhfgdxhqW4hiQB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 10, 2022 at 10:35:47AM +0200, Stefano Brivio wrote: > Add a --version option displaying that, and also include this > information in the log files. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > Makefile | 3 +++ > conf.c | 8 ++++++++ > contrib/fedora/passt.spec | 1 + > log.c | 4 ++-- > passt.1 | 4 ++++ > util.h | 8 ++++++++ > 6 files changed, 26 insertions(+), 2 deletions(-) >=20 > diff --git a/Makefile b/Makefile > index e4c64fe..6b22408 100644 > --- a/Makefile > +++ b/Makefile > @@ -9,6 +9,8 @@ > # Copyright (c) 2021 Red Hat GmbH > # Author: Stefano Brivio > =20 > +VERSION ?=3D $(shell git describe --tags HEAD 2>/dev/null || echo "unkno= wn\ version") > + > RLIMIT_STACK_VAL :=3D $(shell /bin/sh -c 'ulimit -s') > ifeq ($(RLIMIT_STACK_VAL),unlimited) > RLIMIT_STACK_VAL :=3D 1024 > @@ -31,6 +33,7 @@ FLAGS +=3D -DNETNS_RUN_DIR=3D\"/run/netns\" > FLAGS +=3D -DPASST_AUDIT_ARCH=3DAUDIT_ARCH_$(AUDIT_ARCH) > FLAGS +=3D -DRLIMIT_STACK_VAL=3D$(RLIMIT_STACK_VAL) > FLAGS +=3D -DARCH=3D\"$(TARGET_ARCH)\" > +FLAGS +=3D -DVERSION=3D\"$(VERSION)\" > =20 > PASST_SRCS =3D arch.c arp.c checksum.c conf.c dhcp.c dhcpv6.c icmp.c igm= p.c \ > isolation.c lineread.c log.c mld.c ndp.c netlink.c packet.c passt.c \ > diff --git a/conf.c b/conf.c > index f22940b..7c3e346 100644 > --- a/conf.c > +++ b/conf.c > @@ -626,6 +626,7 @@ static void usage(const char *name) > } > info(""); > =20 > + > info( " -d, --debug Be verbose, don't run in background"); > info( " --trace Be extra verbose, implies --debug"); > info( " -q, --quiet Don't print informational messages"); > @@ -640,6 +641,7 @@ static void usage(const char *name) > info( " numeric, or login and group names"); > info( " default: drop to user \"nobody\""); > info( " -h, --help Display this help message and exit"); > + info( " --version Show version and exit"); > =20 > if (strstr(name, "pasta")) { > info( " -I, --ns-ifname NAME namespace interface name"); > @@ -1039,6 +1041,7 @@ void conf(struct ctx *c, int argc, char **argv) > {"trace", no_argument, NULL, 11 }, > {"runas", required_argument, NULL, 12 }, > {"log-size", required_argument, NULL, 13 }, > + {"version", no_argument, NULL, 14 }, > { 0 }, > }; > struct get_bound_ports_ns_arg ns_ports_arg =3D { .c =3D c }; > @@ -1197,6 +1200,11 @@ void conf(struct ctx *c, int argc, char **argv) > usage(argv[0]); > } > break; > + case 14: > + fprintf(stdout, > + c->mode =3D=3D MODE_PASST ? "passt " : "pasta "); > + fprintf(stdout, VERSION_BLOB); > + exit(EXIT_SUCCESS); > case 'd': > if (c->debug) { > err("Multiple --debug options given"); > diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec > index bd60650..f441f5c 100644 > --- a/contrib/fedora/passt.spec > +++ b/contrib/fedora/passt.spec > @@ -48,6 +48,7 @@ This package adds SELinux enforcement to passt(1) and p= asta(1). > %setup -q -n passt-%{git_hash} > =20 > %build > +%global optflags %{optflags} -DVERSION=3D\"%{version}-%{release}.%{_arch= }\" > %set_build_flags > %make_build > =20 > diff --git a/log.c b/log.c > index 993c617..468c730 100644 > --- a/log.c > +++ b/log.c > @@ -172,7 +172,7 @@ void passt_vsyslog(int pri, const char *format, va_li= st ap) > } > =20 > /** > - * logfile_init() - Open log file and write header with PID and path > + * logfile_init() - Open log file and write header with PID, version, pa= th > * @name: Identifier for header: passt or pasta > * @path: Path to log file > * @size: Maximum size of log file: log_cut_size is calculatd here > @@ -196,7 +196,7 @@ void logfile_init(const char *name, const char *path,= size_t size) > =20 > log_size =3D size ? size : LOGFILE_SIZE_DEFAULT; > =20 > - n =3D snprintf(log_header, sizeof(log_header), "%s: %s (%i)", > + n =3D snprintf(log_header, sizeof(log_header), "%s " VERSION ": %s (%i)= ", > name, exe, getpid()); > =20 > if (write(log_file, log_header, n) <=3D 0 || > diff --git a/passt.1 b/passt.1 > index 64236b6..667c1bc 100644 > --- a/passt.1 > +++ b/passt.1 > @@ -124,6 +124,10 @@ Default is to change to user \fInobody\fR if started= as root. > .BR \-h ", " \-\-help > Display a help message and exit. > =20 > +.TP > +.BR \-\-version > +Show version and exit. > + > .TP > .BR \-p ", " \-\-pcap " " \fIfile > Capture tap-facing (that is, guest-side or namespace-side) network packe= ts to > diff --git a/util.h b/util.h > index 1adbf04..f9a8ec6 100644 > --- a/util.h > +++ b/util.h > @@ -6,6 +6,14 @@ > #ifndef UTIL_H > #define UTIL_H > =20 > +#define VERSION_BLOB \ > + VERSION "\n" \ > + "Copyright Red Hat\n" \ > + "GNU Affero GPL version 3 or later " \ > + "\n" \ > + "This is free software: you are free to change and redistribute it.\n" \ > + "There is NO WARRANTY, to the extent permitted by law.\n\n" > + > #ifndef SECCOMP_RET_KILL_PROCESS > #define SECCOMP_RET_KILL_PROCESS SECCOMP_RET_KILL > #endif --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --VvuhfgdxhqW4hiQB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNEtOwACgkQgypY4gEw YSL39g/+IuMjPME82at/PVP/0nCkkE8zwU6Ne+IzcGgfKATZt20kkFoLJYG3zw12 LYHKRhgJ7jt1qUq+GThL29Miaw73b0hfCFDUEtUqmcEagQNUu4V4UYryXIK5aMjp te/7CpwXPH//c0ZiWKNTdfV2qKfkf3Mq47wQVq3Mybf5uI9BNLI9R4zuN42EtcG+ vRVN/XpbaI5zv4wpJWlhiO4VbC1T/9nnkskaPmaTyi10CY37124nbRdesiJer/kt pv4r8/WUtDDr7KoQrfMwAE/CF/jJHm9RMHHamGo/mkgaPqTzHqAY632Xn3IizfK6 HeSfNgkI1otYtQJj1/D2BAlB3qGUPjRGJwp2Lnj+56WWpRAUmOFxtK1r86UD3vSn w3275rfFk1Jh7yz68sQb7cZCVimbFtGaWhocLefnhBS07b/Y+R/3yFRG/NTZL+qg wI+g0K+hHGNVbm/ls8NCr9K1xRznIWffwzLJGxoyuSpmZ7bvEy9YvfUEAWNTY4rv 6qZ9PgAbmar/5vutxfGT/gVKUqcPnS7FFcw9JETHt6A2CPhomMefoejp6L/KoGf5 SRZMxSL3n7ydj4QKU6PuXlSMc3xCW92tKUj9q+Xo5S05Z7h3IYD/sgitpfkNm7J7 pEd2rHj+jKJ55S3y9AqsZh47paJGhgwneO72kdXIj31nU4qCV4k= =CNrZ -----END PGP SIGNATURE----- --VvuhfgdxhqW4hiQB--