From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH 6/8] conf, log, Makefile: Add versioning information Date: Fri, 07 Oct 2022 20:03:52 +1100 Message-ID: In-Reply-To: <20221007101525.28e79ae1@elisabeth> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8594942993685765737==" --===============8594942993685765737== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, Oct 07, 2022 at 10:15:25AM +0200, Stefano Brivio wrote: > On Fri, 7 Oct 2022 17:57:43 +1100 > David Gibson wrote: >=20 > > On Fri, Oct 07, 2022 at 02:47:40AM +0200, Stefano Brivio wrote: > > > Now that we can log to file, this might start to be relevant. =20 > >=20 > > Uh... I dont' understand the connection here. >=20 > Because we might have a pile of log files collected somewhere (or > logs shared by users) and this adds the version to the log file. But how is that different with a system logger? > > > Signed-off-by: Stefano Brivio > > > --- > > > Makefile | 3 +++ > > > conf.c | 12 ++++++++++-- > > > log.c | 4 ++-- > > > passt.1 | 4 ++++ > > > util.h | 8 ++++++++ > > > 5 files changed, 27 insertions(+), 4 deletions(-) > > >=20 > > > diff --git a/Makefile b/Makefile > > > index fafb024..f7ddb84 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 || echo "unknown\ versio= n") > > > + > > > 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 i= gmp.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..4ec3153 100644 > > > --- a/conf.c > > > +++ b/conf.c > > > @@ -626,6 +626,8 @@ static void usage(const char *name) > > > } > > > info(""); > > > =20 > > > + =20 > >=20 > > Extraneous blank line. >=20 > Oops. >=20 > > > + info( " -v, --version Show version and exit"); =20 > >=20 > > I'd suggest just '--version'. '-v' is "verbose" more often than it is > > "version". >=20 > Um, yes, I'll drop -v. >=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"); > > > @@ -993,6 +995,7 @@ void conf(struct ctx *c, int argc, char **argv) > > > { > > > int netns_only =3D 0; > > > struct option options[] =3D { > > > + {"version", no_argument, NULL, 'v' }, > > > {"debug", no_argument, NULL, 'd' }, > > > {"quiet", no_argument, NULL, 'q' }, > > > {"foreground", no_argument, NULL, 'f' }, > > > @@ -1057,9 +1060,9 @@ void conf(struct ctx *c, int argc, char **argv) > > > =20 > > > if (c->mode =3D=3D MODE_PASTA) { > > > c->no_dhcp_dns =3D c->no_dhcp_dns_search =3D 1; > > > - optstring =3D "dqfel:hI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; > > > + optstring =3D "vdqfel:hI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; > > > } else { > > > - optstring =3D "dqfel:hs:p:P:m:a:n:M:g:i:D:S:46t:u:"; > > > + optstring =3D "vdqfel:hs:p:P:m:a:n:M:g:i:D:S:46t:u:"; > > > } > > > =20 > > > c->tcp.fwd_in.mode =3D c->tcp.fwd_out.mode =3D 0; > > > @@ -1197,6 +1200,11 @@ void conf(struct ctx *c, int argc, char **argv) > > > usage(argv[0]); > > > } > > > break; > > > + case 'v': > > > + 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/log.c b/log.c > > > index 85b13fe..2b088c4 100644 > > > --- a/log.c > > > +++ b/log.c > > > @@ -172,7 +172,7 @@ void passt_vsyslog(int pri, const char *format, va_= list 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, = path > > > * @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 *pat= h, 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..c63a439 100644 > > > --- a/passt.1 > > > +++ b/passt.1 > > > @@ -77,6 +77,10 @@ for performance reasons. > > > =20 > > > .SH OPTIONS > > > =20 > > > +.TP > > > +.BR \-v ", " \-\-version > > > +Show version and exit. > > > + > > > .TP > > > .BR \-d ", " \-\-debug > > > Be verbose, don't run in background, don't log to the system logger. > > > diff --git a/util.h b/util.h > > > index 1adbf04..e8f99b6 100644 > > > --- a/util.h > > > +++ b/util.h > > > @@ -6,6 +6,14 @@ > > > #ifndef UTIL_H > > > #define UTIL_H > > > =20 > > > +#define VERSION_BLOB \ > > > + VERSION "\n" \ > > > + "Copyright (C) 2020-2022 Red Hat\n" \ =20 > >=20 > > Fwiw, I believe Red Hat legal suggests simply "Copyright Red Hat". > > AIUI the "(C)" thing is legally meaningless (unlike the word > > "copyright" or the actual =C2=A9 symbol), and the years are unnecessary a= nd > > tend to get out of date. >=20 > I just checked coreutils and gcc, but I see both points, I'll change > this. Yeah.. developer copyright statements have an awful lot of cargo culting. --=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 --===============8594942993685765737== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1NLzYzRUFDZ2tRZ3lwWTRnRXcKWVNKY2doQUFvQ296SEFpWGZ1 eGJYVjZjK3JQVm4wcEt0L2hHclRGVlRiS2RaK3p0eWltRHV6NzZKUGVhSHpnLwo1OWJBK2R3KzZH SGpVQ2kyMUJqOUl1SURVNHJBeklRU3diaWxtM3lzTExDOVFrNXFITlQzUmN5S2NZb1JXRVRQCk11 MERCNGEwQ3VoakViOWI4UUNTa2tqbGVQTWtlV1VKR3d1ZC9yVmlVZDM4VWUxNXFZMGEyaGl6aitz ZldLc04KMUZCcDNsT1VLMHZyY2RrNEJ6Tm16OWFSaUphUk13NlNMRzgwdnVGc0lsUVQvaVk5aXND MTliOWk4OGloODRHSgpzZEtib3QrRTFIMTB1SEYyWDdZL1ZkUVRuWkF1d1g4UEZiNkw0eHZBTEtp bmFqTURxMlhrUHVHV3JiZ0s2Y2dFClZWMW1IbXpxU0tDVndBaElLc00vU0J2eCtIZ0s4NkNwRDJ5 dUE5K25XUktMdjB6WHdsTXlWNHl0aHRHd1puM0sKVE9oaHBXeXpLalk2L2pYZW8zUTV5TGY5Tjgw TU44UXpwNVppdFAxM201MDNOTDdPd2orR3J2U0JhUitTR0V0bwpWZm1VdFZWRE5mdG9rM2JCVzZF bXZXeWFyTzZSbWhRSHhIZlhNMHFVUmlqVS9SOVlVNnNKLzhqcGIxTWFQR1BECmVJRnF5ditJRXI3 OS84ckQ4RVYwSjJRMTVURFF2UXJUSkJVM2ZsQk5DMkdMcWsyMTdmVWFOT0R2dFhQOTdtL1kKTFF6 UXkxb0Y2RjYwZk4wWmtvQUZaRDhFbkkxNEJ5UlY1YTlENWxIeWhLUmpQYjNLOVppL25mRHZQY3Er Q0JtdgoyR3NUR050dEtsZmk1L0JCRXpEdWRnZ0swNzFQcXdySG9QRyttYVBHaXpGYUNvdWl1Ylk9 Cj1KS3pUCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============8594942993685765737==--