From nobody Thu Mar 23 16:05:20 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Pj9D42Vbhz41Vtx; Thu, 23 Mar 2023 16:05:24 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pj9D3534bz3DLx; Thu, 23 Mar 2023 16:05:23 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 3.97.99.33) smtp.mailfrom=cy.schubert@cschubert.com; dmarc=none Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id fLR5pdX2xjvm1fNRKp7x16; Thu, 23 Mar 2023 16:05:22 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id fNRIpAhr6HFsOfNRJpkJne; Thu, 23 Mar 2023 16:05:22 +0000 X-Authority-Analysis: v=2.4 cv=XZqaca15 c=1 sm=1 tr=0 ts=641c78c2 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=k__wU0fu6RkA:10 a=6I5d2MoRAAAA:8 a=pGLkceISAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=e3K2cC5ZDbAh1FsnALUA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 753541FBD; Thu, 23 Mar 2023 09:05:20 -0700 (PDT) Received: from slippy (localhost [IPv6:::1]) by slippy.cwsent.com (Postfix) with ESMTP id 4A5776E6; Thu, 23 Mar 2023 09:05:20 -0700 (PDT) Date: Thu, 23 Mar 2023 09:05:20 -0700 From: Cy Schubert To: Mark Johnston , Jose Luis Duran Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 20b41303140e - main - ping: Print the IP options of the original packet Message-ID: <20230323090520.30554030@slippy> In-Reply-To: <202303191633.32JGXPov003163@gitrepo.freebsd.org> References: <202303191633.32JGXPov003163@gitrepo.freebsd.org> Organization: KOMQUATS X-Mailer: Claws Mail 3.19.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfNh/jk9xs44GRkE/x+LCBJMhMLRoyXul+lCcsuxGO2J3WX0Gb2qsJyXcmv8wvsI30q5bxOuhCHOEunvBuC1uBmKtfX3XMJ1/mdz2c2VvMyh/6BJzGP4o gn86EM80zvfmALPr/KlTPmjsAlQeUrNrUsVjeYioIQpF7gH0oxReETXUZJby6lKO6ieS/+5OWLTOUZC09ODBlz5iLC3B3aJNrkvOdWa3MmOJGwFD/Xv66oFd M5wokTfAoCjWjGSxqVBOkL4VcLAEDPXKK457E7KwevRE7DTAR95ZViNbpi0HSC3yot36DjPdUH/TjRmIttdH6J9WH5Z9iQ020z4jDpsywfmN5Qtu7ggmVD/z /2aq1aAm X-Spamd-Result: default: False [-1.80 / 15.00]; AUTH_NA(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_IN_DNSWL_MED(-0.20)[3.97.99.33:from]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[FreeBSD.org,gmail.com]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US]; RCVD_COUNT_FIVE(0.00)[5]; ARC_NA(0.00)[]; HAS_ORG_HEADER(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[cschubert.com: no valid DMARC record]; TO_DN_SOME(0.00)[]; R_SPF_NA(0.00)[no SPF record]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Queue-Id: 4Pj9D3534bz3DLx X-Spamd-Bar: - X-ThisMailContainsUnwantedMimeParts: N On Sun, 19 Mar 2023 16:33:25 GMT Mark Johnston wrote: > The branch main has been updated by markj: > > URL: https://cgit.FreeBSD.org/src/commit/?id=20b41303140eee4dfb896558fb83600c5f013d39 > > commit 20b41303140eee4dfb896558fb83600c5f013d39 > Author: Jose Luis Duran > AuthorDate: 2023-02-09 15:47:53 +0000 > Commit: Mark Johnston > CommitDate: 2023-03-19 16:23:06 +0000 > > ping: Print the IP options of the original packet > > When an ICMP packet contains an IP packet in its payload, and that > original IP packet contains options, these options were not displayed > accordingly in pr_iph(). > > pr_iph() is a function that prints the original "quoted packet" IP > header, with only an IP struct as an argument. The IP struct does not > contain IP options, and it is not guaranteed that the options will be > contiguous in memory to the IP struct after > d9cacf605e2ac0f704e1ce76357cbfbe6cb63d52. > > Pass the raw ICMP data along with the IP struct, in order to print the > options, if any. > > Reviewed by: markj > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D38469 > --- > sbin/ping/ping.c | 19 ++++++++++--------- > sbin/ping/tests/ping_test.sh | 2 +- > sbin/ping/tests/test_ping.py | 1 - > 3 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c > index fe319bfb70a5..b1721ad72a5c 100644 > --- a/sbin/ping/ping.c > +++ b/sbin/ping/ping.c > @@ -225,7 +225,7 @@ static void pinger(void); > static char *pr_addr(struct in_addr); > static char *pr_ntime(n_time); > static void pr_icmph(struct icmp *, struct ip *, const u_char *const); > -static void pr_iph(struct ip *); > +static void pr_iph(struct ip *, const u_char *); > static void pr_pack(char *, ssize_t, struct sockaddr_in *, struct timespec *); > static void pr_retip(struct ip *, const u_char *); > static void status(int); > @@ -1157,7 +1157,6 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) > struct ip oip; > u_char oip_header_len; > struct icmp oicmp; > - const u_char *oicmp_raw; > > /* > * Get size of IP header of the received packet. > @@ -1355,8 +1354,6 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) > } > > memcpy(&oip, icmp_data_raw, sizeof(struct ip)); > - oicmp_raw = icmp_data_raw + oip_header_len; > - memcpy(&oicmp, oicmp_raw, sizeof(struct icmp)); Coverity is complaining about uninitialized oicmp due to the deletion of the above two lines. > > if (((options & F_VERBOSE) && uid == 0) || > (!(options & F_QUIET2) && > @@ -1366,7 +1363,7 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) > (oicmp.icmp_id == ident))) { > (void)printf("%zd bytes from %s: ", cc, > pr_addr(from->sin_addr)); > - pr_icmph(&icp, &oip, oicmp_raw); > + pr_icmph(&icp, &oip, icmp_data_raw); > } else > return; > } > @@ -1663,14 +1660,13 @@ pr_icmph(struct icmp *icp, struct ip *oip, const u_char *const oicmp_raw) > * Print an IP header with options. > */ > static void > -pr_iph(struct ip *ip) > +pr_iph(struct ip *ip, const u_char *cp) > { > struct in_addr ina; > - u_char *cp; > int hlen; > > hlen = ip->ip_hl << 2; > - cp = (u_char *)ip + sizeof(struct ip); /* point to options */ > + cp = cp + sizeof(struct ip); /* point to options */ > > (void)printf("Vr HL TOS Len ID Flg off TTL Pro cks Src Dst\n"); > (void)printf(" %1x %1x %02x %04x %04x", > @@ -1723,7 +1719,12 @@ pr_addr(struct in_addr ina) > static void > pr_retip(struct ip *ip, const u_char *cp) > { > - pr_iph(ip); > + int8_t hlen; > + > + pr_iph(ip, cp); > + > + hlen = ip->ip_hl << 2; > + cp = cp + hlen; > > if (ip->ip_p == 6) > (void)printf("TCP: from port %u, to port %u (decimal)\n", > diff --git a/sbin/ping/tests/ping_test.sh b/sbin/ping/tests/ping_test.sh > index 9f821ed96360..53383f2fb7bc 100644 > --- a/sbin/ping/tests/ping_test.sh > +++ b/sbin/ping/tests/ping_test.sh > @@ -178,7 +178,7 @@ inject_pip_head() > } > inject_pip_body() > { > - atf_check -s exit:2 -o match:"Destination Host Unreachable" -o not-match:"01010101" python3 $(atf_get_srcdir)/injection.py pip > + atf_check -s exit:2 -o match:"Destination Host Unreachable" -o match:"(01){40}" python3 $(atf_get_srcdir)/injection.py pip > } > inject_pip_cleanup() > { > diff --git a/sbin/ping/tests/test_ping.py b/sbin/ping/tests/test_ping.py > index a9b760ff7aca..79fd332f1c18 100644 > --- a/sbin/ping/tests/test_ping.py > +++ b/sbin/ping/tests/test_ping.py > @@ -893,7 +893,6 @@ Vr HL TOS Len ID Flg off TTL Pro cks Src Dst > "stderr": "", > "redacted": False, > }, > - marks=pytest.mark.skip("XXX currently failing"), > id="_3_1_opts_NOP_40", > ), > pytest.param( > -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e^(i*pi)+1=0