From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 21A8B5A0267 for ; Thu, 27 Oct 2022 00:08:32 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4MyNHJ2jNLz4xGR; Thu, 27 Oct 2022 09:08:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1666822108; bh=bqdYSaMA34ws+WTHCRXRMXIFhJ46KWxVsh711kEzZpE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mdtCx1fjoP9xkhNB0bGktae0GTQJSao27RsaipGFp3IZuQQkVk1oy0+zXfbfyTnor l0Tv49K72L+vu09yeMWmlwqkLZo9OfJuOaHd4QAsI0filx/IPk6XaYpwRjorrG1wzm YxKbcMzKCaWcYx7UBRWrLo8X6mqPOq4ynNU9c7/o= Date: Thu, 27 Oct 2022 08:57:48 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/4] icmp: Add debugging messages for handled replies and requests Message-ID: References: <20221026162531.545374-1-sbrivio@redhat.com> <20221026162531.545374-4-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GsfoJdAKVVJcYlPq" Content-Disposition: inline In-Reply-To: <20221026162531.545374-4-sbrivio@redhat.com> Message-ID-Hash: SDVTMCVMJFUQIAOAQHJCM2WVYTSEIB45 X-Message-ID-Hash: SDVTMCVMJFUQIAOAQHJCM2WVYTSEIB45 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, Paul Holzinger 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: --GsfoJdAKVVJcYlPq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 26, 2022 at 06:25:30PM +0200, Stefano Brivio wrote: > ...instead of just reporting errors. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > icmp.c | 30 +++++++++++++++++++++++++----- > 1 file changed, 25 insertions(+), 5 deletions(-) >=20 > diff --git a/icmp.c b/icmp.c > index 233acf9..9caa7e6 100644 > --- a/icmp.c > +++ b/icmp.c > @@ -88,6 +88,7 @@ void icmp_sock_handler(const struct ctx *c, union epoll= _ref ref, > struct icmp6hdr *ih =3D (struct icmp6hdr *)buf; > =20 > id =3D ntohs(ih->icmp6_identifier); > + seq =3D ntohs(ih->icmp6_sequence); > =20 > /* If bind() fails e.g. because of a broken SELinux policy, this > * might happen. Fix up the identifier to match the sent one. > @@ -97,14 +98,15 @@ void icmp_sock_handler(const struct ctx *c, union epo= ll_ref ref, > =20 > /* In PASTA mode, we'll get any reply we send, discard them. */ > if (c->mode =3D=3D MODE_PASTA) { > - seq =3D ntohs(ih->icmp6_sequence); > - > if (icmp_id_map[V6][id].seq =3D=3D seq) > return; > =20 > icmp_id_map[V6][id].seq =3D seq; > } > =20 > + debug("ICMPv6: echo %s to tap, ID: %i, seq: %i", > + (ih->icmp6_type =3D=3D 128) ? "request" : "reply", id, seq); > + > tap_icmp6_send(c, &sr6->sin6_addr, > tap_ip6_daddr(c, &sr6->sin6_addr), buf, n); > } else { > @@ -112,11 +114,12 @@ void icmp_sock_handler(const struct ctx *c, union e= poll_ref ref, > struct icmphdr *ih =3D (struct icmphdr *)buf; > =20 > id =3D ntohs(ih->un.echo.id); > + seq =3D ntohs(ih->un.echo.sequence); > + > if (id !=3D iref->icmp.id) > ih->un.echo.id =3D htons(iref->icmp.id); > =20 > if (c->mode =3D=3D MODE_PASTA) { > - seq =3D ntohs(ih->un.echo.sequence); > =20 > if (icmp_id_map[V4][id].seq =3D=3D seq) > return; > @@ -124,6 +127,9 @@ void icmp_sock_handler(const struct ctx *c, union epo= ll_ref ref, > icmp_id_map[V4][id].seq =3D seq; > } > =20 > + debug("ICMP: echo %s to tap, ID: %i, seq: %i", > + (ih->type =3D=3D ICMP_ECHO) ? "request" : "reply", id, seq); > + > tap_icmp4_send(c, sr4->sin_addr.s_addr, tap_ip4_daddr(c), > buf, n); > } > @@ -175,14 +181,21 @@ int icmp_tap_handler(const struct ctx *c, int af, c= onst void *addr, > } > =20 > icmp_id_map[V4][id].sock =3D s; > + > + debug("ICMP: new socket %i for echo ID %i", s, id); > } > icmp_id_map[V4][id].ts =3D now->tv_sec; > bitmap_set(icmp_act[V4], id); > =20 > sa.sin_addr =3D *(struct in_addr *)addr; > if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL, > - (struct sockaddr *)&sa, sizeof(sa)) < 0) > + (struct sockaddr *)&sa, sizeof(sa)) < 0) { > debug("ICMP: failed to relay request to socket"); > + } else { > + debug("ICMP: echo %s to socket, ID: %i, seq: %i", > + (ih->type =3D=3D ICMP_ECHO) ? "request" : "reply", > + id, ntohs(ih->un.echo.sequence)); > + } > } else if (af =3D=3D AF_INET6) { > union icmp_epoll_ref iref =3D { .icmp.v6 =3D 1 }; > struct sockaddr_in6 sa =3D { > @@ -214,14 +227,21 @@ int icmp_tap_handler(const struct ctx *c, int af, c= onst void *addr, > } > =20 > icmp_id_map[V6][id].sock =3D s; > + > + debug("ICMPv6: new socket %i for echo ID %i", s, id); > } > icmp_id_map[V6][id].ts =3D now->tv_sec; > bitmap_set(icmp_act[V6], id); > =20 > sa.sin6_addr =3D *(struct in6_addr *)addr; > if (sendto(s, ih, sizeof(*ih) + plen, MSG_NOSIGNAL, > - (struct sockaddr *)&sa, sizeof(sa)) < 1) > + (struct sockaddr *)&sa, sizeof(sa)) < 1) { > debug("ICMPv6: failed to relay request to socket"); > + } else { > + debug("ICMPv6: echo %s to socket, ID: %i, seq: %i", > + (ih->icmp6_type =3D=3D 128) ? "request" : "reply", > + id, ntohs(ih->icmp6_sequence)); > + } > } > =20 > return 1; --=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 --GsfoJdAKVVJcYlPq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNZrVUACgkQgypY4gEw YSKNqA/+LJTLhfKG7da45dXnT3wLqgYcm9VxT/SA1lVZeNV2JFBpSCW+/WCiFyJZ J3nX5m64Ww0i2RV73Zp0a/wAyCi5OvErlLvzx9cDl2Dmekx54h2QwiVWQhHA8RuP NovtWhb6C5IiRdYSYpvmILQq/1KblUf7FVo246BoqphNYh950KFx0OWQaYE5GwDA D1w2+BqtX4rOkZ2vDYYWVx05dyUGkSwMAHWgSK0YWJvqktoj+a8kRwQlJt3Z27rh W+miq7TWrx2EXmBwJ5kuw2MJbVjhuo/uw79a6vpipFQfke5ExYtkRfD66B6KSoRc Gxk7gn3C9NEMi1iVr0H8nGDJtoSPVkldHyWagl3R2c8drRaQp6p6XseFw0gt3Mq4 29713qRj0/DMhcwTN1mlQ2L7CcewU85UKWeKijzbR+0kMoLgFUCShRGvbAehlz93 E7m2+USaedZC7AUFjMJB1+XOepn3Hs68w+l7PwqYYZ7/bFrB46KB6L8tHEVTsWpk 3zSkNzcbTu6uGhs7nXP9F3liFAShpqm8xkxEsy3oJgf61o2j34lPIiTMS0I5VGY2 YayJvfsAUqarVjiuYP0Km+p3pDHexOmu3qS5yUVesLoslJxg8qT/38PT/nJvcOKa +QckfkPuuW0lUXGalTn5xOqvv11NHnn9NmiyApveBmvaMYoSwJA= =Vgp5 -----END PGP SIGNATURE----- --GsfoJdAKVVJcYlPq--